If the keyboard modifier event was received after the key event the
modifier state would end up incorrect.

Signed-off-by: Jonas Ådahl <jad...@gmail.com>
---
 clients/window.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 4d31964..55e7d14 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2211,7 +2211,6 @@ keyboard_handle_key(void *data, struct wl_keyboard 
*keyboard,
        enum wl_keyboard_key_state state = state_w;
        const xkb_keysym_t *syms;
        xkb_keysym_t sym;
-       xkb_mod_mask_t mask;
        struct itimerspec its;
 
        input->display->serial = serial;
@@ -2221,17 +2220,6 @@ keyboard_handle_key(void *data, struct wl_keyboard 
*keyboard,
 
        num_syms = xkb_key_get_syms(input->xkb.state, code, &syms);
 
-       mask = xkb_state_serialize_mods(input->xkb.state,
-                                       XKB_STATE_DEPRESSED |
-                                       XKB_STATE_LATCHED);
-       input->modifiers = 0;
-       if (mask & input->xkb.control_mask)
-               input->modifiers |= MOD_CONTROL_MASK;
-       if (mask & input->xkb.alt_mask)
-               input->modifiers |= MOD_ALT_MASK;
-       if (mask & input->xkb.shift_mask)
-               input->modifiers |= MOD_SHIFT_MASK;
-
        sym = XKB_KEY_NoSymbol;
        if (num_syms == 1)
                sym = syms[0];
@@ -2283,9 +2271,20 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard 
*keyboard,
                          uint32_t group)
 {
        struct input *input = data;
+       xkb_mod_mask_t mask;
 
        xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
                              mods_locked, 0, 0, group);
+       mask = xkb_state_serialize_mods(input->xkb.state,
+                                       XKB_STATE_DEPRESSED |
+                                       XKB_STATE_LATCHED);
+       input->modifiers = 0;
+       if (mask & input->xkb.control_mask)
+               input->modifiers |= MOD_CONTROL_MASK;
+       if (mask & input->xkb.alt_mask)
+               input->modifiers |= MOD_ALT_MASK;
+       if (mask & input->xkb.shift_mask)
+               input->modifiers |= MOD_SHIFT_MASK;
 }
 
 static const struct wl_keyboard_listener keyboard_listener = {
-- 
1.7.9.5

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to