[gtk/fix-wayland-layout-changes: 2/2] wayland: Fix cross-layout accelerators
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-wayland-layout-changes: 2/2] wayland: Fix cross-layout accelerators
- Date: Mon, 15 Mar 2021 21:15:05 +0000 (UTC)
commit e3dcc3d369e090efbc96c629248836523be393ce
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 15 15:23:00 2021 -0400
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.
gdk/gdkevents.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index eb39c95976..f7abfe75b5 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]