]> git.sur5r.net Git - i3/i3/blobdiff - i3-config-wizard/xcb.c
Move get_mod_mask to libi3, use it in i3 and i3-config-wizard
[i3/i3] / i3-config-wizard / xcb.c
index 9a9bf615cd920775f11fab6733a0da6da2d7cc89..753568e3c6cd0409fcf1eed75a5996f16f70d3ed 100644 (file)
 
 #include <X11/keysym.h>
 
-extern xcb_window_t root;
-
-/*
- * Convenience-wrapper around xcb_change_gc which saves us declaring a variable
- *
- */
-void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value) {
-        xcb_change_gc(conn, gc, mask, &value);
-}
+#include "xcb.h"
 
-/*
- * Returns the colorpixel to use for the given hex color (think of HTML).
- *
- * The hex_color has to start with #, for example #FF00FF.
- *
- * NOTE that get_colorpixel() does _NOT_ check the given color code for validity.
- * This has to be done by the caller.
- *
- */
-uint32_t get_colorpixel(xcb_connection_t *conn, char *hex) {
-        char strgroups[3][3] = {{hex[1], hex[2], '\0'},
-                                {hex[3], hex[4], '\0'},
-                                {hex[5], hex[6], '\0'}};
-        uint32_t rgb16[3] = {(strtol(strgroups[0], NULL, 16)),
-                             (strtol(strgroups[1], NULL, 16)),
-                             (strtol(strgroups[2], NULL, 16))};
-
-        return (rgb16[0] << 16) + (rgb16[1] << 8) + rgb16[2];
-}
-
-/*
- * Returns the mask for Mode_switch (to be used for looking up keysymbols by
- * keycode).
- *
- */
-uint32_t get_mod_mask(xcb_connection_t *conn, uint32_t keycode) {
-       xcb_key_symbols_t *symbols = xcb_key_symbols_alloc(conn);
-
-       xcb_get_modifier_mapping_reply_t *modmap_r;
-       xcb_keycode_t *modmap, kc;
-       xcb_keycode_t *modeswitchcodes = xcb_key_symbols_get_keycode(symbols, keycode);
-       if (modeswitchcodes == NULL)
-               return 0;
-
-       modmap_r = xcb_get_modifier_mapping_reply(conn, xcb_get_modifier_mapping(conn), NULL);
-       modmap = xcb_get_modifier_mapping_keycodes(modmap_r);
-
-       for (int i = 0; i < 8; i++)
-               for (int j = 0; j < modmap_r->keycodes_per_modifier; j++) {
-                       kc = modmap[i * modmap_r->keycodes_per_modifier + j];
-                       for (xcb_keycode_t *ktest = modeswitchcodes; *ktest; ktest++) {
-                               if (*ktest != kc)
-                                       continue;
-
-                               free(modeswitchcodes);
-                               free(modmap_r);
-                               return (1 << i);
-                       }
-               }
-
-       return 0;
-}
+extern xcb_window_t root;
+unsigned int xcb_numlock_mask;
 
 /*
  * Opens the window we use for input/output and maps it
@@ -106,11 +48,9 @@ xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t
         mask |= XCB_CW_BACK_PIXEL;
         values[0] = 0;
 
-        mask |= XCB_CW_OVERRIDE_REDIRECT;
-        values[1] = 1;
-
        mask |= XCB_CW_EVENT_MASK;
-       values[2] = XCB_EVENT_MASK_EXPOSURE;
+       values[1] = XCB_EVENT_MASK_EXPOSURE |
+                    XCB_EVENT_MASK_BUTTON_PRESS;
 
         xcb_create_window(conn,
                           XCB_COPY_FROM_PARENT,