wl_keyboard: Add modifier event
authorDaniel Stone <daniel@fooishbar.org>
Wed, 30 May 2012 15:31:47 +0000 (16:31 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 31 May 2012 18:01:56 +0000 (14:01 -0400)
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 <daniel@fooishbar.org>
protocol/wayland.xml
src/wayland-server.c
src/wayland-server.h

index 3979d97..eb09849 100644 (file)
       <arg name="key" type="uint"/>
       <arg name="state" type="uint"/>
     </event>
+
+    <event name="modifiers">
+      <description summary="modifier and group state">
+        Notifies clients that the modifier and/or group state has
+       changed, and it should update its local state.
+      </description>
+
+      <arg name="serial" type="uint"/>
+      <arg name="mods_depressed" type="uint"/>
+      <arg name="mods_latched" type="uint"/>
+      <arg name="mods_locked" type="uint"/>
+      <arg name="group" type="uint"/>
+    </event>
   </interface>
 
   <interface name="wl_touch" version="1">
index d4a70cf..323d32d 100644 (file)
@@ -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
index b1962ea..266b457 100644 (file)
@@ -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 {