forked from AuroraMiddleware/gtk
wayland: Fix cross-layout accelerators
GTK traditionally lets you activate keyboard shortcuts even if they are for a non-active layout. But it is meant to only activate with a keysym from a non-active layout when that symbol is not present in the current layout. That last condition was lost when key event handling was redone for GTK4. Bring it back.
This commit is contained in:
parent
568fe2e97b
commit
e3dcc3d369
@ -1686,6 +1686,24 @@ gdk_key_event_is_modifier (GdkEvent *event)
|
||||
return self->key_is_modifier;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
keyval_in_group (GdkKeymap *keymap,
|
||||
guint keyval,
|
||||
int group)
|
||||
{
|
||||
GdkKeymapKey *keys;
|
||||
guint n_keys;
|
||||
|
||||
gdk_keymap_get_cached_entries_for_keyval (keymap, keyval, &keys, &n_keys);
|
||||
for (int i = 0; i < n_keys; i++)
|
||||
{
|
||||
if (keys[i].group == group)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_key_event_matches:
|
||||
* @event: (type GdkKeyEvent): a key `GdkEvent`
|
||||
@ -1781,10 +1799,9 @@ gdk_key_event_matches (GdkEvent *event,
|
||||
if (keys[i].keycode == keycode &&
|
||||
keys[i].level == level &&
|
||||
/* Only match for group if it's an accel mod */
|
||||
(!group_mod_is_accel_mod || keys[i].group == layout))
|
||||
{
|
||||
return GDK_KEY_MATCH_PARTIAL;
|
||||
}
|
||||
(keys[i].group == layout ||
|
||||
(!group_mod_is_accel_mod && !keyval_in_group (keymap, keyval, layout))))
|
||||
return GDK_KEY_MATCH_PARTIAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user