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 c72da994ba)
This commit is contained in:
Camilla Löwy 2020-06-02 19:54:30 +02:00
parent 63af05c419
commit 5dbca2e2c9
2 changed files with 13 additions and 4 deletions

View File

@ -129,6 +129,7 @@ information on what to include when reporting a bug.
non-printable keys (#1598) non-printable keys (#1598)
- [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
combinaitons (#1598) combinaitons (#1598)
- [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
## Contact ## Contact
@ -333,6 +334,7 @@ skills.
- Torsten Walluhn - Torsten Walluhn
- Patrick Walton - Patrick Walton
- Xo Wang - Xo Wang
- Waris
- Jay Weisskopf - Jay Weisskopf
- Frank Wille - Frank Wille
- Ryogo Yoshimura - Ryogo Yoshimura

View File

@ -870,10 +870,17 @@ static void handleEvents(int timeout)
if (read_ret != 8) if (read_ret != 8)
return; return;
for (i = 0; i < repeats; ++i) if (_glfw.wl.keyboardFocus)
_glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey, {
_glfw.wl.keyboardLastScancode, GLFW_REPEAT, for (i = 0; i < repeats; ++i)
_glfw.wl.xkb.modifiers); {
_glfwInputKey(_glfw.wl.keyboardFocus,
_glfw.wl.keyboardLastKey,
_glfw.wl.keyboardLastScancode,
GLFW_REPEAT,
_glfw.wl.xkb.modifiers);
}
}
} }
if (fds[2].revents & POLLIN) if (fds[2].revents & POLLIN)