From 9a1705c5f5e877d4e68bd0e7eb858f517375ba3f Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 30 May 2012 16:31:47 +0100 Subject: [PATCH] wl_keyboard: Add modifier event This event sends the current keyboard modifier/group state from the compositor to the client, allowing all clients to have a consistent view of the keyboard state (e.g. current layout, Caps Lock, et al). It should be sent after a keyboard enter event, and also immediately after any key event which changes the modifier state. Signed-off-by: Daniel Stone --- protocol/wayland.xml | 13 +++++++++++++ src/wayland-server.c | 19 ++++++++++++++++++- src/wayland-server.h | 3 +++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index 3979d97c..eb098494 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -872,6 +872,19 @@ + + + + Notifies clients that the modifier and/or group state has + changed, and it should update its local state. + + + + + + + + diff --git a/src/wayland-server.c b/src/wayland-server.c index d4a70cfa..323d32da 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -532,9 +532,26 @@ default_grab_key(struct wl_keyboard_grab *grab, } } +static void +default_grab_modifiers(struct wl_keyboard_grab *grab, uint32_t serial, + uint32_t mods_depressed, uint32_t mods_latched, + uint32_t mods_locked, uint32_t group) +{ + struct wl_keyboard *keyboard = grab->keyboard; + struct wl_resource *resource; + + resource = keyboard->focus_resource; + if (!resource) + return; + + wl_keyboard_send_modifiers(resource, serial, mods_depressed, + mods_latched, mods_locked, group); +} + static const struct wl_keyboard_grab_interface default_keyboard_grab_interface = { - default_grab_key + default_grab_key, + default_grab_modifiers, }; WL_EXPORT void diff --git a/src/wayland-server.h b/src/wayland-server.h index b1962eaa..266b4579 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -210,6 +210,9 @@ struct wl_keyboard_grab; struct wl_keyboard_grab_interface { void (*key)(struct wl_keyboard_grab *grab, uint32_t time, uint32_t key, uint32_t state); + void (*modifiers)(struct wl_keyboard_grab *grab, uint32_t serial, + uint32_t mods_depressed, uint32_t mods_latched, + uint32_t mods_locked, uint32_t group); }; struct wl_keyboard_grab {