From f2d3b1000f451003c38933c05a742b76da48aeee Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sun, 3 Nov 2019 14:18:41 -0500 Subject: Introduce wlr_keyboard_group A wlr_keyboard_group allows for multiple keyboard devices to be combined into one logical keyboard. Each keyboard device can only be added to one keyboard group. This helps with the situation where one physical keyboard is exposed as multiple keyboard devices. It is up to the compositors on how they group keyboards together, if at all. Since a wlr_keyboard_group is one logical keyboard, the keys are a set. This means that if a key is pressed on multiple keyboard devices, the key event will only be emitted once, but the internal state will count the number of devices that the key is pressed on. Likewise, the key release will not be emitted until the key is released from all devices. If the compositor wants access to which keys are pressed and released on each keyboard device, the events for those devices can be listened to, as they currently are, in addition to the group keyboard's events. Also, all keyboard devices in the group must share the same keymap. If the keymap's differ, the keyboard device will not be able to be added to the group. Once in the group, if the keymap or effective layout for one keyboard device changes, it will be synced to all keyboard devices in the group. The repeat info and keyboard modifiers are also synced --- include/wlr/types/meson.build | 1 + include/wlr/types/wlr_keyboard.h | 2 ++ include/wlr/types/wlr_keyboard_group.h | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 include/wlr/types/wlr_keyboard_group.h (limited to 'include/wlr') diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build index 288fd1c5..aee5c6d9 100644 --- a/include/wlr/types/meson.build +++ b/include/wlr/types/meson.build @@ -16,6 +16,7 @@ install_headers( 'wlr_input_inhibitor.h', 'wlr_input_method_v2.h', 'wlr_keyboard.h', + 'wlr_keyboard_group.h', 'wlr_layer_shell_v1.h', 'wlr_linux_dmabuf_v1.h', 'wlr_list.h', diff --git a/include/wlr/types/wlr_keyboard.h b/include/wlr/types/wlr_keyboard.h index e16df7a7..9bd4acd9 100644 --- a/include/wlr/types/wlr_keyboard.h +++ b/include/wlr/types/wlr_keyboard.h @@ -49,6 +49,7 @@ struct wlr_keyboard_modifiers { struct wlr_keyboard { const struct wlr_keyboard_impl *impl; + struct wlr_keyboard_group *group; char *keymap_string; size_t keymap_size; @@ -84,6 +85,7 @@ struct wlr_keyboard { struct wl_signal modifiers; struct wl_signal keymap; struct wl_signal repeat_info; + struct wl_signal destroy; } events; void *data; diff --git a/include/wlr/types/wlr_keyboard_group.h b/include/wlr/types/wlr_keyboard_group.h new file mode 100644 index 00000000..023887f3 --- /dev/null +++ b/include/wlr/types/wlr_keyboard_group.h @@ -0,0 +1,37 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_KEYBOARD_GROUP_H +#define WLR_TYPES_WLR_KEYBOARD_GROUP_H + +#include +#include "wlr/types/wlr_keyboard.h" +#include "wlr/types/wlr_input_device.h" + +struct wlr_keyboard_group { + struct wlr_keyboard keyboard; + struct wlr_input_device *input_device; + struct wl_list devices; // keyboard_group_device::link + struct wl_list keys; // keyboard_group_key::link + void *data; +}; + +struct wlr_keyboard_group *wlr_keyboard_group_create(void); + +struct wlr_keyboard_group *wlr_keyboard_group_from_wlr_keyboard( + struct wlr_keyboard *keyboard); + +bool wlr_keyboard_group_add_keyboard(struct wlr_keyboard_group *group, + struct wlr_keyboard *keyboard); + +void wlr_keyboard_group_remove_keyboard(struct wlr_keyboard_group *group, + struct wlr_keyboard *keyboard); + +void wlr_keyboard_group_destroy(struct wlr_keyboard_group *group); + +#endif -- cgit v1.2.3