]> Dogcows Code - chaz/openbox/commitdiff
allow the use of keycodes directly in key bindings
authorDana Jansens <danakj@orodu.net>
Wed, 17 Sep 2003 02:37:52 +0000 (02:37 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 17 Sep 2003 02:37:52 +0000 (02:37 +0000)
openbox/translate.c

index 2903bf3c6ec727bf1a31b2571776c08d86698fcb..b9b2f2af5fc703b16ce4a21b5c3e14963ea7eb96 100644 (file)
@@ -89,13 +89,24 @@ gboolean translate_key(char *str, guint *state, guint *keycode)
        *state |= m;
     }
 
-    /* figure out the keycode */
-    sym = XStringToKeysym(l);
-    if (sym == NoSymbol) {
-       g_warning("Invalid key name '%s' in key binding.", l);
-       goto translation_fail;
+    if (!g_ascii_strncasecmp("0x", l, 2)) {
+        gchar *end;
+
+        /* take it directly */
+        *keycode = strtol(l, &end, 16);
+        if (*l == '\0' || *end != '\0') {
+            g_warning("Invalid key code '%s' in key binding.", l);
+            goto translation_fail;
+        }
+    } else {
+        /* figure out the keycode */
+        sym = XStringToKeysym(l);
+        if (sym == NoSymbol) {
+            g_warning("Invalid key name '%s' in key binding.", l);
+            goto translation_fail;
+        }
+        *keycode = XKeysymToKeycode(ob_display, sym);
     }
-    *keycode = XKeysymToKeycode(ob_display, sym);
     if (!*keycode) {
        g_warning("Key '%s' does not exist on the display.", l); 
        goto translation_fail;
This page took 0.026581 seconds and 4 git commands to generate.