[Xfce4-commits] <libxfce4ui:xfce-4.10> Get rid of FinallyGetModifiersForKeycode.

Jérôme Guelfucci noreply at xfce.org
Sat May 4 12:10:07 CEST 2013


Updating branch refs/heads/xfce-4.10
         to a43f8e098cbef25ea0fd042c64e367aedf205397 (commit)
       from c760cb5474c4cea89e923587df68cc3c4767f676 (commit)

commit a43f8e098cbef25ea0fd042c64e367aedf205397
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Thu Dec 20 10:32:39 2012 +0100

    Get rid of FinallyGetModifiersForKeycode.
    
    It simply does not work as expected and the logic seems boggus.

 libxfce4kbd-private/xfce-shortcuts-grabber.c |  108 +++-----------------------
 1 files changed, 12 insertions(+), 96 deletions(-)

diff --git a/libxfce4kbd-private/xfce-shortcuts-grabber.c b/libxfce4kbd-private/xfce-shortcuts-grabber.c
index 0118a70..9b0947c 100644
--- a/libxfce4kbd-private/xfce-shortcuts-grabber.c
+++ b/libxfce4kbd-private/xfce-shortcuts-grabber.c
@@ -213,85 +213,21 @@ xfce_shortcuts_grabber_ungrab_all (XfceShortcutsGrabber *grabber)
 
 
 
-/* Return the modifier mask that needs to be pressed to produce key in the
- * given group (keyboard layout) and level ("shift level").
- *
- * Taken from libkeybinder
- * Copyright (C) 2010 Ulrik Sverdrup <ulrik.sverdrup at gmail.com>
- */
-static GdkModifierType
-FinallyGetModifiersForKeycode (XkbDescPtr xkb,
-                               KeyCode    key,
-                               uint       group,
-                               uint       level)
-{
-  XkbKeyTypeRec *type;
-  int            nKeyGroups;
-  int            effectiveGroup;
-  int            k;
-
-  nKeyGroups = XkbKeyNumGroups (xkb, key);
-
-  if ((!XkbKeycodeInRange (xkb, key)) || (nKeyGroups == 0))
-    return MODIFIERS_ERROR;
-
-  /* Taken from GDK's MyEnhancedXkbTranslateKeyCode */
-  /* find the offset of the effective group */
-  effectiveGroup = group;
-
-  if (effectiveGroup >= nKeyGroups)
-    {
-      unsigned groupInfo = XkbKeyGroupInfo (xkb,key);
-
-      switch (XkbOutOfRangeGroupAction(groupInfo))
-        {
-          default:
-            effectiveGroup %= nKeyGroups;
-            break;
-          case XkbClampIntoRange:
-            effectiveGroup = nKeyGroups-1;
-            break;
-          case XkbRedirectIntoRange:
-            effectiveGroup = XkbOutOfRangeGroupNumber (groupInfo);
-            if (effectiveGroup >= nKeyGroups)
-              effectiveGroup = 0;
-            break;
-        }
-    }
-
-  type = XkbKeyKeyType (xkb, key, effectiveGroup);
-
-  for (k = 0; k < type->map_count; k++)
-    {
-      if (type->map[k].active && type->map[k].level == level)
-        {
-          if (type->preserve)
-            return (type->map[k].mods.mask & ~type->preserve[k].mask);
-          else
-            return type->map[k].mods.mask;
-        }
-    }
-
-  return MODIFIERS_NONE;
-}
-
-
-
 static void
 xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
                              XfceKey              *key,
                              gboolean              grab)
 {
-  GdkKeymapKey *keys;
-  XkbDescPtr    xmap;
-  GdkDisplay   *display;
-  GdkKeymap    *keymap;
-  gchar        *shortcut_name;
-  guint         modifiers;
-  guint         k;
-  gint          i, j;
-  gint          n_keys;
-  gint          screens;
+  GdkModifierType  numlock_modifier;
+  GdkKeymapKey    *keys;
+  GdkDisplay      *display;
+  GdkKeymap       *keymap;
+  gchar           *shortcut_name;
+  guint            modifiers;
+  guint            k;
+  gint             i, j;
+  gint             n_keys;
+  gint             screens;
 
   g_return_if_fail (XFCE_IS_SHORTCUTS_GRABBER (grabber));
   g_return_if_fail (key != NULL);
@@ -324,22 +260,16 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
       return;
     }
 
-  xmap = XkbGetMap (GDK_DISPLAY_XDISPLAY (display),
-                    XkbAllClientInfoMask,
-                    XkbUseCoreKbd);
-
   /* Get all keys generating keyval */
   if (!gdk_keymap_get_entries_for_keyval (keymap,key->keyval,
                                           &keys, &n_keys))
     {
-      XkbFreeClientMap (xmap, 0, TRUE);
       TRACE ("Got no keys for keyval");
       return;
     }
 
   if (n_keys == 0)
     {
-      XkbFreeClientMap (xmap, 0, TRUE);
       g_free (keys);
 
       TRACE ("Got 0 keys for keyval");
@@ -350,21 +280,8 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
     {
       /* Grab all hardware keys generating keyval */
 
-      GdkModifierType add_modifiers;
-
       TRACE ("Keycode: %d", keys[i].keycode);
 
-      add_modifiers = FinallyGetModifiersForKeycode (xmap,
-                                                     keys[i].keycode,
-                                                     keys[i].group,
-                                                     keys[i].level);
-
-      if (add_modifiers == MODIFIERS_ERROR)
-        {
-          TRACE ("Error when getting modifiers for keycode");
-          continue;
-        }
-
       for (j = 0; j < screens; j++)
         {
           /* Do the grab on all screens */
@@ -395,7 +312,7 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
               if (grab)
                 XGrabKey (GDK_DISPLAY_XDISPLAY (display),
                           keys[i].keycode,
-                          add_modifiers | modifiers | mod_masks [k],
+                          modifiers | mod_masks [k],
                           root_window,
                           False,
                           GrabModeAsync,
@@ -403,7 +320,7 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
               else
                 XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
                             keys[i].keycode,
-                            add_modifiers | modifiers | mod_masks [k],
+                            modifiers | mod_masks [k],
                             root_window);
             }
 
@@ -420,7 +337,6 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
     }
 
   g_free (keys);
-  XkbFreeClientMap (xmap, 0, TRUE);
 }
 
 


More information about the Xfce4-commits mailing list