[Xfce4-commits] <libxfce4ui:jeromeg/keyboard-shortcuts> Improve key comparison.

Jérôme Guelfucci noreply at xfce.org
Fri Dec 28 15:54:07 CET 2012


Updating branch refs/heads/jeromeg/keyboard-shortcuts
         to e56596a37ffdb4fe8fda4491466e6f826270accc (commit)
       from ea42d959502588e8cb5e9e08a4bd799bf9718f6d (commit)

commit e56596a37ffdb4fe8fda4491466e6f826270accc
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Tue Dec 18 08:21:03 2012 +0100

    Improve key comparison.
    
    Remove horrible hardcoded hack and use the recommanded way of comparison
    described in the GDK documentation instead.

 libxfce4kbd-private/xfce-shortcuts-grabber.c |   27 ++++---------------------
 1 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/libxfce4kbd-private/xfce-shortcuts-grabber.c b/libxfce4kbd-private/xfce-shortcuts-grabber.c
index a94351d..b8d2898 100644
--- a/libxfce4kbd-private/xfce-shortcuts-grabber.c
+++ b/libxfce4kbd-private/xfce-shortcuts-grabber.c
@@ -432,6 +432,7 @@ struct EventKeyFindContext
 {
   XfceShortcutsGrabber *grabber;
   GdkModifierType       modifiers;
+  GdkModifierType       consumed;
   guint                 keyval;
   const gchar          *result;
 };
@@ -443,30 +444,13 @@ find_event_key (const gchar                *shortcut,
                 XfceKey                    *key,
                 struct EventKeyFindContext *context)
 {
-  GdkModifierType ignored;
-
   g_return_val_if_fail (context != NULL, FALSE);
 
   TRACE ("Comparing to %s", shortcut);
 
-  ignored = 0;
-
-  /* Accept MOD1 + META as MOD1 */
-  if (key->modifiers & context->modifiers & GDK_MOD1_MASK)
-    {
-      TRACE ("Ignoring Meta Mask");
-      ignored |= GDK_META_MASK;
-    }
-
-  /* Accept SUPER + HYPER as SUPER */
-  if (key->modifiers & context->modifiers & GDK_SUPER_MASK)
-    {
-      TRACE ("Ignoring Hyper Mask");
-      ignored |= GDK_HYPER_MASK;
-    }
-
-  if ((key->modifiers & ~ignored) == (context->modifiers & ~ignored)
-      && key->keyval == context->keyval)
+  if ((key->modifiers & ~context->consumed & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK))
+      == (context->modifiers)
+      && (key->keyval == context->keyval))
     {
       context->result = shortcut;
 
@@ -514,13 +498,12 @@ xfce_shortcuts_grabber_event_filter (GdkXEvent            *gdk_xevent,
                                        XkbGroupForCoreState (xevent->xkey.state),
                                        &keyval, NULL, NULL, &consumed);
 
-  /* Get the modifiers */
   modifiers &= ~consumed;
-  gdk_keymap_add_virtual_modifiers (keymap, &modifiers);
   modifiers &= mod_mask;
 
   context.keyval = keyval;
   context.modifiers = modifiers;
+  context.consumed = consumed;
 
   raw_shortcut_name = gtk_accelerator_name (keyval, modifiers);
   TRACE ("Looking for %s", raw_shortcut_name);


More information about the Xfce4-commits mailing list