diff options
-rw-r--r-- | src/xcb_io.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/xcb_io.c b/src/xcb_io.c index ba892f8..d40ac10 100644 --- a/src/xcb_io.c +++ b/src/xcb_io.c @@ -102,6 +102,21 @@ static void call_handlers(Display *dpy, xcb_generic_reply_t *buf) _XError(dpy, (xError *) buf); } +static xcb_generic_event_t * wait_or_poll_for_event(Display *dpy, int wait) +{ + xcb_connection_t *c = dpy->xcb->connection; + xcb_generic_event_t *event; + if(wait && !dpy->head) + { + UnlockDisplay(dpy); + event = xcb_wait_for_event(c); + LockDisplay(dpy); + } + else + event = xcb_poll_for_event(c); + return event; +} + static void process_responses(Display *dpy, int wait_for_first_event, xcb_generic_error_t **current_error, unsigned int current_request) { void *reply; @@ -110,16 +125,7 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi PendingRequest *req; xcb_connection_t *c = dpy->xcb->connection; if(!event && dpy->xcb->event_owner == XlibOwnsEventQueue) - { - if(wait_for_first_event) - { - UnlockDisplay(dpy); - event = xcb_wait_for_event(c); - LockDisplay(dpy); - } - else - event = xcb_poll_for_event(c); - } + event = wait_or_poll_for_event(dpy, wait_for_first_event); while(1) { @@ -134,7 +140,7 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi break; } handle_event(dpy, event); - event = xcb_poll_for_event(c); + event = wait_or_poll_for_event(dpy, wait_for_first_event); } else if(req && req->waiters != -1) { |