]> git.sur5r.net Git - i3/i3/commitdiff
i3-input: remove dependency on xcb-event
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 18 Mar 2011 16:32:37 +0000 (17:32 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 18 Mar 2011 16:32:37 +0000 (17:32 +0100)
i3-input/main.c

index 6efbbdec56b03761d20c04f5f4abc1bac5b62b6f..ea1e61322cdc2bf2d01292b19f413250fb5dd400 100644 (file)
@@ -306,14 +306,6 @@ int main(int argc, char *argv[]) {
         xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screens);
         root = root_screen->root;
 
-        /* Set up event handlers for key press and key release */
-        xcb_event_handlers_t evenths;
-        memset(&evenths, 0, sizeof(xcb_event_handlers_t));
-        xcb_event_handlers_init(conn, &evenths);
-        xcb_event_set_key_press_handler(&evenths, handle_key_press, NULL);
-        xcb_event_set_key_release_handler(&evenths, handle_key_release, NULL);
-        xcb_event_set_expose_handler(&evenths, handle_expose, NULL);
-
         modeswitchmask = get_mod_mask(conn, XK_Mode_switch);
         numlockmask = get_mod_mask(conn, XK_Num_Lock);
        symbols = xcb_key_symbols_alloc(conn);
@@ -359,7 +351,32 @@ int main(int argc, char *argv[]) {
 
         xcb_flush(conn);
 
-        xcb_event_wait_for_event_loop(&evenths);
+        xcb_generic_event_t *event;
+        while ((event = xcb_wait_for_event(conn)) != NULL) {
+                if (event->response_type == 0) {
+                        fprintf(stderr, "X11 Error received! sequence %x\n", event->sequence);
+                        continue;
+                }
+
+                /* Strip off the highest bit (set if the event is generated) */
+                int type = (event->response_type & 0x7F);
+
+                switch (type) {
+                        case XCB_KEY_PRESS:
+                                handle_key_press(NULL, conn, (xcb_key_press_event_t*)event);
+                                break;
+
+                        case XCB_KEY_RELEASE:
+                                handle_key_release(NULL, conn, (xcb_key_release_event_t*)event);
+                                break;
+
+                        case XCB_EXPOSE:
+                                handle_expose(NULL, conn, (xcb_expose_event_t*)event);
+                                break;
+                }
+
+                free(event);
+        }
 
         return 0;
 }