From 52133a36909d4f328902f703496c02df377d1b19 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 14 Dec 2021 09:29:01 +0100 Subject: [PATCH] =?UTF-8?q?Wayland:=20Continue=20poll()=20if=20timerfd=20c?= =?UTF-8?q?an=E2=80=99t=20be=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case the key repeat timerfd was interrupted before read(), the cursor timerfd wasn’t read at all even when it could. Related to #1711 (cherry picked from commit 68879081cb39f50bd65d12e0f1869f5970dc71b9) --- README.md | 2 +- src/wl_window.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7c59dea9..c274a1cc 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ information on what to include when reporting a bug. ## Changelog -There is nothing here yet. + - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) ## Contact diff --git a/src/wl_window.c b/src/wl_window.c index db32f449..ec4e60cd 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -867,10 +867,7 @@ static void handleEvents(int timeout) if (fds[1].revents & POLLIN) { read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats)); - if (read_ret != 8) - return; - - if (_glfw.wl.keyboardFocus) + if (read_ret == 8 && _glfw.wl.keyboardFocus) { for (i = 0; i < repeats; ++i) { @@ -886,10 +883,8 @@ static void handleEvents(int timeout) if (fds[2].revents & POLLIN) { read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)); - if (read_ret != 8) - return; - - incrementCursorImage(_glfw.wl.pointerFocus); + if (read_ret == 8) + incrementCursorImage(_glfw.wl.pointerFocus); } } else