From 5dbca2e2c9b2b021ebe4fb5f9ba5506360b3e10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 2 Jun 2020 19:54:30 +0200 Subject: [PATCH] Wayland: Fix repeated keys reported to NULL window This fixes a race between the key repeat logic and the surface leave event handler, which could result in repeated keys being reported with a window of NULL. Fixes #1704. (cherry picked from commit c72da994bac2a21ef07f891a44ab49570d650dec) --- README.md | 2 ++ src/wl_window.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9fc19451..292ceef8 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ information on what to include when reporting a bug. non-printable keys (#1598) - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout combinaitons (#1598) + - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704) ## Contact @@ -333,6 +334,7 @@ skills. - Torsten Walluhn - Patrick Walton - Xo Wang + - Waris - Jay Weisskopf - Frank Wille - Ryogo Yoshimura diff --git a/src/wl_window.c b/src/wl_window.c index 61785fe7..0cc725a5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -870,10 +870,17 @@ static void handleEvents(int timeout) if (read_ret != 8) return; - for (i = 0; i < repeats; ++i) - _glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey, - _glfw.wl.keyboardLastScancode, GLFW_REPEAT, - _glfw.wl.xkb.modifiers); + if (_glfw.wl.keyboardFocus) + { + for (i = 0; i < repeats; ++i) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + _glfw.wl.keyboardLastKey, + _glfw.wl.keyboardLastScancode, + GLFW_REPEAT, + _glfw.wl.xkb.modifiers); + } + } } if (fds[2].revents & POLLIN)