[Xfce4-commits] [xfce/xfwm4] 02/02: keyboard: Ignore unsupported modifiers

noreply at xfce.org noreply at xfce.org
Sat Apr 30 19:16:29 CEST 2016


This is an automated email from the git hooks/post-receive script.

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit 7f498183106547e9682828b66f4cbc527453158f
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Sat Apr 30 19:13:07 2016 +0200

    keyboard: Ignore unsupported modifiers
    
    Bug: 10760
    
    If a given keyboard modifier is not supported, ignore the shortcut.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/keyboard.c | 44 ++++++++++++++++++++++++++++++++------------
 src/keyboard.h |  3 ++-
 src/settings.c |  6 +++++-
 3 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index fa35265..c32ed18 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -73,29 +73,44 @@ getKeycode (Display *dpy, const char *str)
     return XKeysymToKeycode (dpy, keysym);
 }
 
-guint
-getModifierMap (const char *str)
+static gboolean
+addModifierMap (guint *map, guint mask)
 {
-    guint map;
+    if (!mask)
+    {
+        return FALSE;
+    }
+
+    *map |= mask;
 
-    gtk_accelerator_parse (str, NULL, &map);
+    return TRUE;
+}
 
-    if ((map & GDK_SUPER_MASK) == GDK_SUPER_MASK)
+gboolean
+getModifierMap (const char *str, guint *map)
+{
+    gboolean ret;
+
+    ret = TRUE;
+    gtk_accelerator_parse (str, NULL, map);
+
+    ret = TRUE;
+    if ((*map & GDK_SUPER_MASK) == GDK_SUPER_MASK)
     {
-        map |= SuperMask;
+        ret &= addModifierMap (map, SuperMask);
     }
 
-    if ((map & GDK_HYPER_MASK) == GDK_HYPER_MASK)
+    if ((*map & GDK_HYPER_MASK) == GDK_HYPER_MASK)
     {
-        map |= HyperMask;
+        ret &= addModifierMap (map, HyperMask);
     }
 
-    if ((map & GDK_META_MASK) == GDK_META_MASK)
+    if ((*map & GDK_META_MASK) == GDK_META_MASK)
     {
-        map |= MetaMask;
+        ret &= addModifierMap (map, MetaMask);
     }
 
-    return map & MODIFIER_MASK & ~IGNORE_MASK;
+    return ret;
 }
 
 void
@@ -119,8 +134,13 @@ parseKeyString (Display * dpy, MyKey * key, const char *str)
         return;
     }
 
+    if (!getModifierMap (str, &key->modifier))
+    {
+        g_message (_("Unsupported keyboard modifier '%s'"), str);
+        key->modifier = 0;
+        return;
+    }
     key->keycode = getKeycode (dpy, str);
-    key->modifier = getModifierMap (str);
 
     TRACE ("keycode = 0x%x, modifier = 0x%x", key->keycode, key->modifier);
 }
diff --git a/src/keyboard.h b/src/keyboard.h
index f505832..1e8210b 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -45,7 +45,8 @@ extern unsigned int ScrollLockMask;
 extern unsigned int SuperMask;
 extern unsigned int HyperMask;
 
-guint                    getModifierMap                         (const char *);
+gboolean                 getModifierMap                         (const char *,
+                                                                 guint *);
 void                     parseKeyString                         (Display *,
                                                                  MyKey *,
                                                                  const char *);
diff --git a/src/settings.c b/src/settings.c
index 20348b0..ce2f8c0 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -155,7 +155,11 @@ set_easy_click (ScreenInfo *screen_info, const char *modifier)
     else
     {
         modstr = g_strdup_printf ("<%s>", modifier);
-        screen_info->params->easy_click = getModifierMap (modstr);
+        if (!getModifierMap (modstr, &screen_info->params->easy_click))
+        {
+            g_message (_("Unsupported keyboard modifier '%s'"), modstr);
+            screen_info->params->easy_click = 0;
+        }
         g_free (modstr);
     }
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list