aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-11-03 14:18:41 -0500
committerSimon Ser <contact@emersion.fr>2019-11-05 20:05:49 +0100
commitf2d3b1000f451003c38933c05a742b76da48aeee (patch)
treefb9b5e180dada9e91c824d741e5f3a9d6e73ef43 /include
parent626c98d754253de10a7db0482e44459c7f75a85d (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/wlr/types/meson.build1
-rw-r--r--include/wlr/types/wlr_keyboard.h2
-rw-r--r--include/wlr/types/wlr_keyboard_group.h37
3 files changed, 40 insertions, 0 deletions
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 <wayland-server-core.h>
+#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