[mutter] wayland-keyboard: Send modifiers after the key event



commit 4040a70781f81f1d508390635fe1e0db9a6b8790
Author: Rui Matos <tiagomatos gmail com>
Date:   Tue Jul 22 11:24:56 2014 +0200

    wayland-keyboard: Send modifiers after the key event
    
    The key event should be interpreted by clients with the modifier state
    as it was before the event itself just as in X11 input events.
    Achieving this in wayland is a matter of sending the key event first
    and the modifiers after (if needed).
    
    This isn't really specified in the wayland protocol but it matches
    weston's behavior and should avoid corner cases in clients.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738238

 src/wayland/meta-wayland-keyboard.c |   18 +++++++++---------
 src/wayland/meta-wayland-keyboard.h |    1 +
 2 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 101748c..60c7f80 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -434,16 +434,10 @@ meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
                               const ClutterKeyEvent *event)
 {
   gboolean is_press = event->type == CLUTTER_KEY_PRESS;
-  struct xkb_state *state = keyboard->xkb_info.state;
-  enum xkb_state_component changed_state;
-
-  changed_state = xkb_state_update_key (state,
-                                        event->hardware_keycode,
-                                        is_press ? XKB_KEY_DOWN : XKB_KEY_UP);
-  if (changed_state == 0)
-    return;
 
-  notify_modifiers (keyboard);
+  keyboard->mods_changed = xkb_state_update_key (keyboard->xkb_info.state,
+                                                 event->hardware_keycode,
+                                                 is_press ? XKB_KEY_DOWN : XKB_KEY_UP);
 }
 
 gboolean
@@ -469,6 +463,12 @@ meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
   else
     meta_verbose ("No wayland surface is focused, continuing normal operation\n");
 
+  if (keyboard->mods_changed != 0)
+    {
+      notify_modifiers (keyboard);
+      keyboard->mods_changed = 0;
+    }
+
   return handled;
 }
 
diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h
index 799b5ac..b4a8c52 100644
--- a/src/wayland/meta-wayland-keyboard.h
+++ b/src/wayland/meta-wayland-keyboard.h
@@ -70,6 +70,7 @@ struct _MetaWaylandKeyboard
   uint32_t focus_serial;
 
   MetaWaylandXkbInfo xkb_info;
+  enum xkb_state_component mods_changed;
 
   GSettings *settings;
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]