Skip to content
Snippets Groups Projects
Commit 604f22eb authored by Jonas Ådahl's avatar Jonas Ådahl
Browse files

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: default avatarJonas Ådahl <jadahl@gmail.com>
Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
parent dbbc0911
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment