]> Dogcows Code - chaz/openbox/blobdiff - openbox/modkeys.c
have stacking_restack_request return a bool that says if it did something with TopIf...
[chaz/openbox] / openbox / modkeys.c
index dc5220825cc613eb5ab099580b1c8dab570aa28d..3346a88dccd2f78f021e829d9c90526cf7aeb605 100644 (file)
@@ -20,6 +20,7 @@
 #include "openbox.h"
 
 #include <X11/Xlib.h>
+#include <X11/keysym.h>
 
 /* These masks are constants and the modifier keys are bound to them as
    anyone sees fit:
 static void set_modkey_mask(guchar mask, KeySym sym);
 
 static XModifierKeymap *modmap;
+static KeySym *keymap;
+static gint min_keycode, max_keycode, keysyms_per_keycode;
 /* This is a bitmask of the different masks for each modifier key */
 static guchar modkeys_keys[OB_MODKEY_NUM_KEYS];
 
 void modkeys_startup(gboolean reconfigure)
 {
-    KeySym *keymap;
     gint i, j, k;
-    gint min_keycode, max_keycode, keysyms_per_keycode;
 
     /* reset the keys to not be bound to any masks */
     for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i)
@@ -63,22 +64,25 @@ void modkeys_startup(gboolean reconfigure)
             KeySym sym;
             /* get a keycode that is bound to the mask (i) */
             KeyCode keycode = modmap->modifiermap[i*modmap->max_keypermod + j];
-            /* go through each keysym bound to the given keycode */
-            for (k = 0; k < keysyms_per_keycode; ++k) {
-                sym = keymap[(keycode-min_keycode) * keysyms_per_keycode + k];
-                if (sym != NoSymbol) {
-                    /* bind the key to the mask (e.g. Alt_L => Mod1Mask) */
-                    set_modkey_mask(nth_mask(i), sym);
+            if (keycode) {
+                /* go through each keysym bound to the given keycode */
+                for (k = 0; k < keysyms_per_keycode; ++k) {
+                    sym = keymap[(keycode-min_keycode) * keysyms_per_keycode +
+                                 k];
+                    if (sym != NoSymbol) {
+                        /* bind the key to the mask (e.g. Alt_L => Mod1Mask) */
+                        set_modkey_mask(nth_mask(i), sym);
+                    }
                 }
             }
         }
     }
-    XFree(keymap);
 }
 
 void modkeys_shutdown(gboolean reconfigure)
 {
     XFreeModifiermap(modmap);
+    XFree(keymap);
 }
 
 guint modkeys_keycode_to_mask(guint keycode)
@@ -138,3 +142,16 @@ static void set_modkey_mask(guchar mask, KeySym sym)
     else if (sym == XK_Meta_L || sym == XK_Meta_R)
         modkeys_keys[OB_MODKEY_KEY_META] |= mask;
 }
+
+KeyCode modkeys_sym_to_code(KeySym sym)
+{
+    gint i, j;
+
+    /* go through each keycode and look for the keysym */
+    for (i = min_keycode; i <= max_keycode; ++i)
+        for (j = 0; j < keysyms_per_keycode; ++j)
+            if (sym == keymap[(i-min_keycode) * keysyms_per_keycode + j])
+                return i;
+    return 0;
+}
+
This page took 0.020906 seconds and 4 git commands to generate.