[gtk+] Bug 736125 - The default gtk accelerator mod mask does not include all default backend modifiers



commit c55ff6e41fb3c6272b5e7a084c8273dea60d7dee
Author: John Ralls <jralls ceridwen us>
Date:   Wed Dec 24 16:10:12 2014 -0800

    Bug 736125 - The default gtk accelerator mod mask does not include all default backend modifiers

 gdk/gdkkeys.c               |    4 ++++
 gdk/gdktypes.h              |    8 +++++++-
 gdk/quartz/gdkkeys-quartz.c |    5 +++++
 gtk/gtkaccelgroup.c         |   12 ++++++------
 4 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index c651205..9302f42 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -653,6 +653,10 @@ gdk_keymap_real_get_modifier_mask (GdkKeymap         *keymap,
     case GDK_MODIFIER_INTENT_SHIFT_GROUP:
       return 0;
 
+    case GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK:
+      return (GDK_SHIFT_MASK   | GDK_CONTROL_MASK | GDK_MOD1_MASK    |
+             GDK_SUPER_MASK   | GDK_HYPER_MASK   | GDK_META_MASK);
+
     default:
       g_return_val_if_reached (0);
     }
diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h
index 4c355aa..252922d 100644
--- a/gdk/gdktypes.h
+++ b/gdk/gdktypes.h
@@ -291,6 +291,11 @@ typedef enum
  *  input methods, and for use cases like typeahead search.
  * @GDK_MODIFIER_INTENT_SHIFT_GROUP: the modifier that switches between keyboard
  *  groups (AltGr on X11/Windows and Option/Alt on OS X).
+ * @GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK: The set of modifier masks accepted
+ * as modifiers in accelerators. Needed because Command is mapped to MOD2 on
+ * OSX, which is widely used, but on X11 MOD2 is NumLock and using that for a
+ * mod key is problematic at best.
+ * Ref: https://bugzilla.gnome.org/show_bug.cgi?id=736125.
  *
  * This enum is used with gdk_keymap_get_modifier_mask()
  * in order to determine what modifiers the
@@ -309,7 +314,8 @@ typedef enum
   GDK_MODIFIER_INTENT_EXTEND_SELECTION,
   GDK_MODIFIER_INTENT_MODIFY_SELECTION,
   GDK_MODIFIER_INTENT_NO_TEXT_INPUT,
-  GDK_MODIFIER_INTENT_SHIFT_GROUP
+  GDK_MODIFIER_INTENT_SHIFT_GROUP,
+  GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK,
 } GdkModifierIntent;
 
 typedef enum
diff --git a/gdk/quartz/gdkkeys-quartz.c b/gdk/quartz/gdkkeys-quartz.c
index b2a52ed..f985783 100644
--- a/gdk/quartz/gdkkeys-quartz.c
+++ b/gdk/quartz/gdkkeys-quartz.c
@@ -761,6 +761,11 @@ gdk_quartz_keymap_get_modifier_mask (GdkKeymap         *keymap,
     case GDK_MODIFIER_INTENT_SHIFT_GROUP:
       return GDK_MOD1_MASK;
 
+    case GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK:
+      return (GDK_SHIFT_MASK   | GDK_CONTROL_MASK | GDK_MOD1_MASK    |
+             GDK_MOD2_MASK    | GDK_SUPER_MASK   | GDK_HYPER_MASK   |
+             GDK_META_MASK);
+
     default:
       g_return_val_if_reached (0);
     }
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c
index 0523efe..15a27d4 100644
--- a/gtk/gtkaccelgroup.c
+++ b/gtk/gtkaccelgroup.c
@@ -73,12 +73,7 @@ static void accel_closure_invalidate     (gpointer    data,
 static guint  signal_accel_activate      = 0;
 static guint  signal_accel_changed       = 0;
 static guint  quark_acceleratable_groups = 0;
-static guint  default_accel_mod_mask     = (GDK_SHIFT_MASK   |
-                                            GDK_CONTROL_MASK |
-                                            GDK_MOD1_MASK    |
-                                            GDK_SUPER_MASK   |
-                                            GDK_HYPER_MASK   |
-                                            GDK_META_MASK);
+static guint  default_accel_mod_mask     = 0;
 
 enum {
   PROP_0,
@@ -1752,5 +1747,10 @@ gtk_accelerator_set_default_mod_mask (GdkModifierType default_mod_mask)
 GdkModifierType
 gtk_accelerator_get_default_mod_mask (void)
 {
+  if (!default_accel_mod_mask)
+    default_accel_mod_mask =
+      gdk_keymap_get_modifier_mask (gdk_keymap_get_default (),
+                                   GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK);
+
   return default_accel_mod_mask;
 }


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