From 31f08cc7fc2208ca49ca53db3d6e30358e1d21fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Nov 2023 16:47:35 +0100 Subject: [PATCH] Wayland: Fix heuristics for what counts as events The Wayland implementation of glfwWaitEvents* keeps waiting until it sees evidence that a significant event has been processed. However, this included updating an animated cursor (not a significant event) but did not include previously buffered Wayland events or libdecor events (definitely significant events). This commit corrects these cases. (cherry picked from commit d097e35743ee49d38811a89ea29c7f2525dc8d6a) --- src/wl_window.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 7b0737e7..985a5711 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1149,7 +1149,10 @@ static void handleEvents(double* timeout) while (!event) { while (wl_display_prepare_read(_glfw.wl.display) != 0) - wl_display_dispatch_pending(_glfw.wl.display); + { + if (wl_display_dispatch_pending(_glfw.wl.display) > 0) + return; + } // If an error other than EAGAIN happens, we have likely been disconnected // from the Wayland session; try to handle that the best we can. @@ -1207,14 +1210,14 @@ static void handleEvents(double* timeout) uint64_t repeats; if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) - { incrementCursorImage(_glfw.wl.pointerFocus); - event = GLFW_TRUE; - } } if (fds[3].revents & POLLIN) - libdecor_dispatch(_glfw.wl.libdecor.context, 0); + { + if (libdecor_dispatch(_glfw.wl.libdecor.context, 0) > 0) + event = GLFW_TRUE; + } } }