core: Ignore locked modifiers in keycombo machinery

Locked modifiers should probably not have an effect on keybindings
while toggled. this is most relevant for modifiers that can be
either/both pressed or locked (e.g. Caps Lock key), if used in
keybindings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3369>
This commit is contained in:
Carlos Garnacho 2023-11-06 11:48:48 +01:00 committed by Marge Bot
parent 38228da550
commit 8cae7ff0f6

View File

@ -1896,6 +1896,16 @@ meta_key_binding_has_handler_func (MetaKeyBinding *binding)
return (!!binding->handler->func || !!binding->handler->default_func);
}
static ClutterModifierType
get_modifiers (ClutterEvent *event)
{
ClutterModifierType pressed, latched;
clutter_event_get_key_state (event, &pressed, &latched, NULL);
return pressed | latched;
}
static gboolean
process_event (MetaDisplay *display,
MetaWindow *window,
@ -1906,14 +1916,14 @@ process_event (MetaDisplay *display,
(xkb_keycode_t) clutter_event_get_key_code ((ClutterEvent *) event);
MetaResolvedKeyCombo resolved_combo = { &keycode, 1 };
MetaKeyBinding *binding;
ClutterModifierType modifiers;
/* we used to have release-based bindings but no longer. */
if (clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_RELEASE)
return FALSE;
resolved_combo.mask =
mask_from_event_params (keys,
clutter_event_get_state ((ClutterEvent *) event));
modifiers = get_modifiers ((ClutterEvent *) event);
resolved_combo.mask = mask_from_event_params (keys, modifiers);
binding = get_keybinding (keys, &resolved_combo);
@ -1995,7 +2005,7 @@ process_special_modifier_key (MetaDisplay *display,
hardware_keycode = clutter_event_get_key_code ((ClutterEvent *) event);
time_ms = clutter_event_get_time ((ClutterEvent *) event);
device = clutter_event_get_device ((ClutterEvent *) event);
modifiers = clutter_event_get_state ((ClutterEvent *) event);
modifiers = get_modifiers ((ClutterEvent *) event);
if (*modifier_press_only)
{
@ -2167,6 +2177,7 @@ process_iso_next_group (MetaDisplay *display,
gboolean activate;
xkb_keycode_t keycode =
(xkb_keycode_t) clutter_event_get_key_code ((ClutterEvent *) event);
ClutterModifierType modifiers;
xkb_mod_mask_t mask;
int i, j;
@ -2174,8 +2185,8 @@ process_iso_next_group (MetaDisplay *display,
return FALSE;
activate = FALSE;
mask = mask_from_event_params (keys,
clutter_event_get_state ((ClutterEvent *) event));
modifiers = get_modifiers ((ClutterEvent *) event);
mask = mask_from_event_params (keys, modifiers);
for (i = 0; i < keys->n_iso_next_group_combos; ++i)
{
@ -3954,15 +3965,15 @@ process_keybinding_key_event (MetaDisplay *display,
MetaKeyBindingManager *keys = &display->key_binding_manager;
xkb_keycode_t keycode =
(xkb_keycode_t) clutter_event_get_key_code ((ClutterEvent *) event);
ClutterModifierType modifiers;
MetaResolvedKeyCombo resolved_combo = { &keycode, 1 };
MetaKeyBinding *binding;
if (clutter_event_type ((ClutterEvent *) event) == CLUTTER_KEY_RELEASE)
return FALSE;
resolved_combo.mask =
mask_from_event_params (keys,
clutter_event_get_state ((ClutterEvent *) event));
modifiers = get_modifiers ((ClutterEvent *) event);
resolved_combo.mask = mask_from_event_params (keys, modifiers);
binding = get_keybinding (keys, &resolved_combo);
if (!binding)