From c9fe96102d6e179baa22274376a273a27c37bdd2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 21 Aug 2023 12:03:26 +0200 Subject: [PATCH] xwayland/xwm: extract read loop to separate function --- xwayland/xwm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/xwayland/xwm.c b/xwayland/xwm.c index f25e4734b..5b6a07b31 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; - } - 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); }