From 23da6c2426932dcb2057849eec9e1d79c34fc405 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 12 Mar 2020 19:43:15 +0100 Subject: [PATCH] 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 --- src/core/keybindings.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 2cf705598..7f930874f 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, @@ -2120,6 +2129,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)) {