]> git.sur5r.net Git - i3/i3/commitdiff
Also support xcb-keysyms < 0.3.4 when using bindsym (Thanks ch3ka)
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 2 Nov 2009 22:15:08 +0000 (23:15 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 2 Nov 2009 22:15:08 +0000 (23:15 +0100)
src/config.c

index 0e94afce2df73d351d6ff28cf9565151a2baf389..363b5246fa3f7511caf6b39e94e6863fce6acd82 100644 (file)
@@ -114,14 +114,23 @@ void grab_all_keys(xcb_connection_t *conn) {
                         continue;
                 }
 
+#ifdef OLD_XCB_KEYSYMS_API
+                bind->number_keycodes = 1;
+                xcb_keycode_t code = xcb_key_symbols_get_keycode(keysyms, keysym);
+                LOG("Translated symbol \"%s\" to 1 keycode (%d)\n", bind->symbol, code);
+                grab_keycode_for_binding(conn, bind, code);
+                bind->translated_to = smalloc(sizeof(xcb_keycode_t));
+                memcpy(bind->translated_to, &code, sizeof(xcb_keycode_t));
+#else
+                uint32_t last_keycode = 0;
                 xcb_keycode_t *keycodes = xcb_key_symbols_get_keycode(keysyms, keysym);
                 if (keycodes == NULL) {
                         LOG("Could not translate symbol \"%s\"\n", bind->symbol);
                         continue;
                 }
 
-                uint32_t last_keycode = 0;
                 bind->number_keycodes = 0;
+
                 for (xcb_keycode_t *walk = keycodes; *walk != 0; walk++) {
                         /* We hope duplicate keycodes will be returned in order
                          * and skip them */
@@ -135,6 +144,7 @@ void grab_all_keys(xcb_connection_t *conn) {
                 bind->translated_to = smalloc(bind->number_keycodes * sizeof(xcb_keycode_t));
                 memcpy(bind->translated_to, keycodes, bind->number_keycodes * sizeof(xcb_keycode_t));
                 free(keycodes);
+#endif
         }
 }