[gnome-control-center/wip/gbsneto/new-keyboard-panel: 2/9] keyboard: avoid stray Meta modified



commit 0b84de9cf2d4fcaf8b077925c97fea3abdf71ada
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jul 28 13:29:20 2016 -0300

    keyboard: avoid stray Meta modified
    
    While using the Keyboard shortcut editor dialog under
    Wayland, the user receives a <Meta> key even when this
    key isn't present in the keyboard.
    
    This is probably the result of Wayland inheriting from
    X's xkb.
    
    To work around that, simply filter out this modified when
    outside an Apple OS (which does have this key).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769063

 panels/keyboard/cc-keyboard-shortcut-editor.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-shortcut-editor.c b/panels/keyboard/cc-keyboard-shortcut-editor.c
index 1d17686..d80ccf1 100644
--- a/panels/keyboard/cc-keyboard-shortcut-editor.c
+++ b/panels/keyboard/cc-keyboard-shortcut-editor.c
@@ -24,6 +24,15 @@
 #include "cc-keyboard-shortcut-editor.h"
 #include "keyboard-shortcuts.h"
 
+/*
+ * Workaround to stop receiving a stray Meta modifier.
+ */
+#ifdef __APPLE__
+#define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK | GDK_META_MASK)
+#else
+#define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
+#endif
+
 struct _CcKeyboardShortcutEditor
 {
   GtkDialog           parent;
@@ -447,7 +456,7 @@ cc_keyboard_shortcut_editor_key_press_event (GtkWidget   *widget,
   if (!editing)
     return GTK_WIDGET_CLASS (cc_keyboard_shortcut_editor_parent_class)->key_press_event (widget, event);
 
-  real_mask = event->state & gtk_accelerator_get_default_mod_mask ();
+  real_mask = event->state & gtk_accelerator_get_default_mod_mask () & ALL_ACCELS_MASK;
 
   /* A single Escape press cancels the editing */
   if (!event->is_modifier && real_mask == 0 && event->keyval == GDK_KEY_Escape)


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