From: Michael Stapelberg Date: Mon, 2 Nov 2009 22:15:08 +0000 (+0100) Subject: Also support xcb-keysyms < 0.3.4 when using bindsym (Thanks ch3ka) X-Git-Tag: 3.d~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2a0b1adab9f2720379cb5d82d6e35d7b1d4a25a1;p=i3%2Fi3 Also support xcb-keysyms < 0.3.4 when using bindsym (Thanks ch3ka) --- diff --git a/src/config.c b/src/config.c index 0e94afce..363b5246 100644 --- a/src/config.c +++ b/src/config.c @@ -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 } }