From 188d4c18cc7070d98781ebb762a61e4f5b136b3d Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Sat, 7 Aug 2010 02:19:25 +0200 Subject: [PATCH] Merge handle_xcb_event() into xcb_chk_cb() --- i3bar/src/xcb.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 21d7df39..2b339412 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -123,25 +123,6 @@ void handle_button(xcb_button_press_event_t *event) { i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, buffer); } -/* - * An X-Event occured, we determine, what kind and call the appropriate handler - * - * FIXME: Merge this in ev_chk_cb(), the additional call is superflous - * - */ -void handle_xcb_event(xcb_generic_event_t *event) { - switch (event->response_type & ~0x80) { - case XCB_EXPOSE: - /* Expose-events happen, when the window needs to be redrawn */ - draw_bars(); - break; - case XCB_BUTTON_PRESS: - /* Button-press-events are mouse-buttons clicked on one of our bars */ - handle_button((xcb_button_press_event_t*) event); - break; - } -} - /* * This function is called immediately bevor the main loop locks. We flush xcb * then (and only then) @@ -161,8 +142,19 @@ void xcb_prep_cb(struct ev_loop *loop, ev_prepare *watcher, int revenst) { */ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) { xcb_generic_event_t *event; - if ((event = xcb_poll_for_event(xcb_connection)) != NULL) { - handle_xcb_event(event); + if ((event = xcb_poll_for_event(xcb_connection)) == NULL) { + return; + } + + switch (event->response_type & ~0x80) { + case XCB_EXPOSE: + /* Expose-events happen, when the window needs to be redrawn */ + draw_bars(); + break; + case XCB_BUTTON_PRESS: + /* Button-press-events are mouse-buttons clicked on one of our bars */ + handle_button((xcb_button_press_event_t*) event); + break; } FREE(event); } -- 2.39.5