[gtk/shortcuts-rebased-again: 97/117] shortcuttrigger: Filter a few modifiers out



commit eab3a5097ad06d31e074ab10e2b7818025705afe
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon May 13 22:35:16 2019 -0300

    shortcuttrigger: Filter a few modifiers out
    
    Copying the code from GtkKeyHash, filter out X11 modifiers and
    Caps Lock from events. Unfortunately, legacy X11 modifiers can
    be present even when running full Wayland, due to XKB.

 gtk/gtkshortcuttrigger.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gtk/gtkshortcuttrigger.c b/gtk/gtkshortcuttrigger.c
index 43a9e77c1e..b1e968ad6d 100644
--- a/gtk/gtkshortcuttrigger.c
+++ b/gtk/gtkshortcuttrigger.c
@@ -499,6 +499,7 @@ gtk_keyval_trigger_trigger (GtkShortcutTrigger *trigger,
                             const GdkEvent     *event,
                             gboolean            enable_mnemonics)
 {
+  const GdkModifierType legacy_x11_modifiers = GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK;
   GtkKeyvalTrigger *self = (GtkKeyvalTrigger *) trigger;
   GdkModifierType modifiers;
   guint keyval;
@@ -515,6 +516,9 @@ gtk_keyval_trigger_trigger (GtkShortcutTrigger *trigger,
   else
     keyval = gdk_keyval_to_lower (keyval);
 
+  /* Filter legacy X11 modifiers and Caps lock out */
+  modifiers &= ~(legacy_x11_modifiers | GDK_LOCK_MASK);
+
   return keyval == self->keyval && modifiers == self->modifiers;
 }
 


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