Exclude MOD1 from the virtual modifier mapping



Hi all,

as a fallout of the recent cross-platform modifier
key fixes that make Quartz work, it seems I broke
modifiers on X11.

The problem is that by enabling virtual modifiers
(META, SUPER, HYPER) in GtkCellRendererAccel, they
are now actually used :) which means that on a default
PC keyboard keymap on X11, which maps MOD1 to META,
entering Alt+foo now results in Alt+Meta+foo.

Now almost all of GTK+ treats MOD1 as ALT, they
are actually synonyms. I propose to simply go through
with this "definition", and exclude MOD1 from any
mapping, such as SHIFT and CONTROL aren't mappable
to virtual either. This would nail down the MOD1 == ALT
mapping that is so far only done by *alnmost* all
the code in GTK+, which is inconsistent.

See attached patch, please comment.

Regards,
--Mitch

diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c
index 5b7295b..80bf711 100644
--- a/gdk/x11/gdkkeys-x11.c
+++ b/gdk/x11/gdkkeys-x11.c
@@ -1489,13 +1489,12 @@ _gdk_x11_keymap_add_virt_mods (GdkKeymap       *keymap,
   keymap = GET_EFFECTIVE_KEYMAP (keymap);
   keymap_x11 = GDK_X11_KEYMAP (keymap);
 
-  for (i = 3; i < 8; i++)
+  /* See comment in add_virtual_modifiers() */
+  for (i = 4; i < 8; i++)
     {
       if ((1 << i) & *modifiers)
         {
-          if (keymap_x11->modmap[i] & GDK_MOD1_MASK)
-            *modifiers |= GDK_MOD1_MASK;
-          else if (keymap_x11->modmap[i] & GDK_SUPER_MASK)
+          if (keymap_x11->modmap[i] & GDK_SUPER_MASK)
             *modifiers |= GDK_SUPER_MASK;
           else if (keymap_x11->modmap[i] & GDK_HYPER_MASK)
             *modifiers |= GDK_HYPER_MASK;
@@ -1515,12 +1514,16 @@ gdk_x11_keymap_add_virtual_modifiers (GdkKeymap       *keymap,
   keymap = GET_EFFECTIVE_KEYMAP (keymap);
   keymap_x11 = GDK_X11_KEYMAP (keymap);
 
-  for (i = 3; i < 8; i++)
+  /*  This loop used to start at 3, which included MOD1 in the
+   *  virtual mapping. However, all of GTK+ treats MOD1 as a
+   *  synonym for Alt, and does not expect it to be mapped around,
+   *  therefore it's more sane to simply treat MOD1 like SHIFT and
+   *  CONTROL, which are not mappable either.
+   */
+  for (i = 4; i < 8; i++)
     {
       if ((1 << i) & *state)
         {
-          if (keymap_x11->modmap[i] & GDK_MOD1_MASK)
-            *state |= GDK_MOD1_MASK;
           if (keymap_x11->modmap[i] & GDK_SUPER_MASK)
             *state |= GDK_SUPER_MASK;
           if (keymap_x11->modmap[i] & GDK_HYPER_MASK)
@@ -1589,7 +1592,8 @@ gdk_x11_keymap_map_virtual_modifiers (GdkKeymap       *keymap,
     {
       if (*state & vmods[j])
         {
-          for (i = 3; i < 8; i++)
+          /* See comment in add_virtual_modifiers() */
+          for (i = 4; i < 8; i++)
             {
               if (keymap_x11->modmap[i] & vmods[j])
                 {


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