Introduce seat wide button and key count API
authorJonas Ådahl <jadahl@gmail.com>
Tue, 1 Apr 2014 19:57:45 +0000 (21:57 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 22 Apr 2014 22:07:40 +0000 (00:07 +0200)
commit604f22eb795c6ba6faff15ba53e00ae0109cda33
tree7b8c759a543924b7ae447f564ca372fd1a043513
parentdbbc09112383a1dac6b39d9d9e9099c8898d5ee4
Introduce seat wide button and key count API

Compositors will need to keep provide virtual devices of supported
generic device types (pointer, keyboard, touch etc). Events from each
device capable of a certain device type abstraction should be combined
as if it was only one device.

For key and button events this means counting presses of every key or
button. With this patch, libinput provides two new API for doing just
this; libinput_event_pointer_get_seat_button_count() and
libinput_event_keyboard_get_seat_key_count().

With these functions, a compositor can sort out what key or button events
that should be ignored for a virtual device. This could for example
look like:

event = libinput_get_event(libinput);
switch (libinput_event_get_type(event)) {
...
case LIBINPUT_EVENT_POINTER_BUTTON:
device = libinput_event_get_device(event);
seat = libinput_event_get_seat(device);
pevent = libinput_event_get_pointer_event(event);

if (libinput_event_pointer_get_button_state(pevent) &&
    libinput_event_pointer_get_seat_button_count(pevent) == 1)
notify_pointer_button_press(seat);
else if (libinput_event_pointer_get_button_state(pevent) &&
 libinput_event_pointer_get_seat_button_count(pevent) == 0)
notify_pointer_button_release(seat);
break;
...
}

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev.c
src/libinput-private.h
src/libinput.c
src/libinput.h
tools/event-debug.c