diff --git a/xwayland/xwm.c b/xwayland/xwm.c index f25e4734..5b6a07b3 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1736,16 +1736,10 @@ static void xwm_handle_unhandled_event(struct wlr_xwm *xwm, xcb_generic_event_t #endif } -static int x11_event_handler(int fd, uint32_t mask, void *data) { +static int read_x11_events(struct wlr_xwm *xwm) { int count = 0; - xcb_generic_event_t *event; - struct wlr_xwm *xwm = data; - - if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { - xwm_destroy(xwm); - return 0; - } + xcb_generic_event_t *event; while ((event = xcb_poll_for_event(xwm->xcb_conn))) { count++; @@ -1804,6 +1798,18 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) { free(event); } + return count; +} + +static int x11_event_handler(int fd, uint32_t mask, void *data) { + struct wlr_xwm *xwm = data; + + if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { + xwm_destroy(xwm); + return 0; + } + + int count = read_x11_events(xwm); if (count) { xcb_flush(xwm->xcb_conn); }