From 06700c90ef5bc9004aef8105441bb4096766908d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 4 May 2011 19:33:43 +0200 Subject: [PATCH] Remove dependency on xcb-event (Thanks Felicitus) --- common.mk | 2 +- i3-input/main.c | 1 - include/i3.h | 1 - src/sighandler.c | 17 ++++++++++------- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/common.mk b/common.mk index bfa6f80b..ce2a59b1 100644 --- a/common.mk +++ b/common.mk @@ -37,12 +37,12 @@ CFLAGS += -DOLD_XCB_KEYSYMS_API endif LDFLAGS += -lm -LDFLAGS += -lxcb-event LDFLAGS += -lxcb-keysyms ifeq ($(shell pkg-config --exists xcb-util || echo 1),1) CFLAGS += -DXCB_COMPAT LDFLAGS += -lxcb-atom LDFLAGS += -lxcb-aux +LDFLAGS += -lxcb-event else LDFLAGS += -lxcb-util endif diff --git a/i3-input/main.c b/i3-input/main.c index fc9afd30..cfae5bf8 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/include/i3.h b/include/i3.h index f081a129..0012e53f 100644 --- a/include/i3.h +++ b/include/i3.h @@ -9,7 +9,6 @@ * */ #include -#include #include #include diff --git a/src/sighandler.c b/src/sighandler.c index 162edbc8..17fbe5d1 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -156,12 +156,6 @@ void handle_signal(int sig, siginfo_t *info, void *data) { xcb_connection_t *conn = global_conn; - /* setup event handler for key presses */ - xcb_event_handlers_t sig_evenths; - memset(&sig_evenths, 0, sizeof(xcb_event_handlers_t)); - xcb_event_handlers_init(conn, &sig_evenths); - xcb_event_set_key_press_handler(&sig_evenths, sig_handle_key_press, NULL); - i3Font *font = load_font(conn, config.font); /* width and height of the popup window, so that the text fits in */ @@ -202,7 +196,16 @@ void handle_signal(int sig, siginfo_t *info, void *data) { xcb_flush(conn); } - xcb_event_wait_for_event_loop(&sig_evenths); + xcb_generic_event_t *event; + /* Yay, more own eventhandlers… */ + while ((event = xcb_wait_for_event(conn))) { + /* Strip off the highest bit (set if the event is generated) */ + int type = (event->response_type & 0x7F); + if (type == XCB_KEY_PRESS) { + sig_handle_key_press(NULL, conn, (xcb_key_press_event_t*)event); + } + free(event); + } } /* -- 2.39.2