From 63a7b0bb9941abc1b5be5da0a5ea1b8e2ecce1cc Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Sun, 28 Jul 2019 01:45:33 +0100 Subject: wl: Tidy up imv_window_wait_for_event --- src/wl_window.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 9a7ded7..a6b16ae 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -747,22 +747,17 @@ void imv_window_wait_for_event(struct imv_window *window, double timeout) }; nfds_t nfds = sizeof fds / sizeof *fds; - while (wl_display_prepare_read(window->wl_display)) { - wl_display_dispatch_pending(window->wl_display); + if (wl_display_prepare_read(window->wl_display)) { + /* If an event's already in the wayland queue we return */ + return; } wl_display_flush(window->wl_display); - int rc = poll(fds, nfds, timeout * 1000); - if (rc < 0) { - wl_display_cancel_read(window->wl_display); - return; - } + poll(fds, nfds, timeout * 1000); - /* Handle any new wayland events */ if (fds[0].revents & POLLIN) { wl_display_read_events(window->wl_display); - wl_display_dispatch_pending(window->wl_display); } else { wl_display_cancel_read(window->wl_display); } -- cgit v1.2.3