diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-07-28 01:45:33 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-07-28 01:45:33 +0100 |
commit | 63a7b0bb9941abc1b5be5da0a5ea1b8e2ecce1cc (patch) | |
tree | 2a5ea63edb4b5fb389d249b048a7ddaa5c7753c8 | |
parent | eb54830c332ebac52f8cd58f3bb5b209c1adcc85 (diff) | |
download | imv-63a7b0bb9941abc1b5be5da0a5ea1b8e2ecce1cc.tar.gz |
wl: Tidy up imv_window_wait_for_event
-rw-r--r-- | src/wl_window.c | 13 |
1 files 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); } |