[mutter/gnome-3-34] keybindings: Check the special modifiers specifically



commit fd8ccbac829cbe4f9b2f7c5cbd1eea191661e7e5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Mar 12 19:43:15 2020 +0100

    keybindings: Check the special modifiers specifically
    
    Make sure it is only the special modifier (hardcoded to 1 currently)
    which is being pressed (not counting locked modifiers) before notifying
    that the special modifier is pressed, as we are interested in it being
    pressed alone and not in combination with other modifier keys.
    
    This helps in two ways:
    - Pressing alt, then ctrl, then releasing both won't trigger the locate
      pointer action.
    - Pressing alt, then ctrl, then down/up to switch workspace won't interpret
      the last up/down keypress as an additional key on top of the special ctrl
      modifier, thus won't be forwarded down to the focused client in the last
      second.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/issues/812
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
    (cherry picked from commit 23da6c2426932dcb2057849eec9e1d79c34fc405)

 src/core/keybindings.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index b86272541..fadbc90fc 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -63,6 +63,15 @@
 #define META_KEY_BINDING_PRIMARY_LAYOUT 0
 #define META_KEY_BINDING_SECONDARY_LAYOUT 1
 
+/* Only for special modifier keys */
+#define IGNORED_MODIFIERS (CLUTTER_LOCK_MASK |          \
+                           CLUTTER_MOD2_MASK |          \
+                           CLUTTER_BUTTON1_MASK |       \
+                           CLUTTER_BUTTON2_MASK |       \
+                           CLUTTER_BUTTON3_MASK |       \
+                           CLUTTER_BUTTON4_MASK |       \
+                           CLUTTER_BUTTON5_MASK)
+
 static gboolean add_builtin_keybinding (MetaDisplay          *display,
                                         const char           *name,
                                         GSettings            *settings,
@@ -2114,6 +2123,7 @@ process_special_modifier_key (MetaDisplay          *display,
       return TRUE;
     }
   else if (event->type == CLUTTER_KEY_PRESS &&
+           (event->modifier_state & ~(IGNORED_MODIFIERS)) == 0 &&
            resolved_key_combo_has_keycode (resolved_key_combo,
                                            event->hardware_keycode))
     {


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