Author: olivier
Date: 2007-02-13 20:25:24 +0000 (Tue, 13 Feb 2007)
New Revision: 24971

Modified:
   xfwm4/trunk/mcs-plugin/xfwm4_shortcuteditor.c
   xfwm4/trunk/src/keyboard.c
Log:
Add support for keycode when no keysym is available (bug #2503)

Modified: xfwm4/trunk/mcs-plugin/xfwm4_shortcuteditor.c
===================================================================
--- xfwm4/trunk/mcs-plugin/xfwm4_shortcuteditor.c       2007-02-13 20:25:01 UTC 
(rev 24970)
+++ xfwm4/trunk/mcs-plugin/xfwm4_shortcuteditor.c       2007-02-13 20:25:24 UTC 
(rev 24971)
@@ -757,6 +757,12 @@
     g_free (accelerator);
     g_strfreev (shortcuts);
 
+    /* Use keycode if unknown keysym */
+    if (!strlen (shortcut_string))
+    {
+        g_snprintf (shortcut_string, sizeof (shortcut_string), "0x%X", (guint) 
event->hardware_keycode);
+    }
+
     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (itf->treeview3));
 
     /* Apply change */

Modified: xfwm4/trunk/src/keyboard.c
===================================================================
--- xfwm4/trunk/src/keyboard.c  2007-02-13 20:25:01 UTC (rev 24970)
+++ xfwm4/trunk/src/keyboard.c  2007-02-13 20:25:24 UTC (rev 24971)
@@ -38,6 +38,29 @@
 unsigned int SuperMask;
 unsigned int HyperMask;
 
+static gboolean
+getKeycode (Display *dpy, const char *str, KeyCode *keycode)
+{
+    unsigned int value;
+    KeySym keysym;
+
+    keysym = XStringToKeysym (str);
+    if (keysym == NoSymbol)
+    {
+        if (sscanf (str, "0x%X", (unsigned int *) &value) != 1)
+        {
+            *keycode = 0;
+            return FALSE;
+        }
+        *keycode = (KeyCode) value;
+    }
+    else
+    {
+        *keycode = XKeysymToKeycode (dpy, keysym);
+    }
+    return TRUE;
+}
+
 int
 getModifierMap (char *str)
 {
@@ -120,12 +143,12 @@
     if (k)
     {
         /* There is a modifier */
-        key->keycode = XKeysymToKeycode (dpy, XStringToKeysym (++k));
+        getKeycode (dpy, ++k, &key->keycode);
         key->modifier = getModifierMap (str);
     }
     else
     {
-        key->keycode = XKeysymToKeycode (dpy, XStringToKeysym (str));
+        getKeycode (dpy, str, &key->keycode);
         key->modifier = 0;
     }
 }

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to