Wayland: Fix key repeat on very old compositors

The client-side key repeat timer fd was only created for wl_seat version
4 or later, but was then used unconditionally during event processing.

Rather than have this mechanism do nothing in a more correct way on
wl_seat version 3 or earlier (which is very old by now), this commit
creates the key repeat timer fd and then sets (hopefully gentle)
hardcoded repeat delay and rate.
This commit is contained in:
Camilla Löwy
2026-02-09 19:48:45 +01:00
parent c4684b288d
commit a98badf088
3 changed files with 18 additions and 7 deletions
+10 -7
View File
@@ -137,13 +137,6 @@ static void registryHandleGlobal(void* userData,
wl_registry_bind(registry, name, &wl_seat_interface,
_glfw_min(4, version));
_glfwAddSeatListenerWayland(_glfw.wl.seat);
if (wl_seat_get_version(_glfw.wl.seat) >=
WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
{
_glfw.wl.keyRepeatTimerfd =
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
}
}
}
else if (strcmp(interface, "wl_data_device_manager") == 0)
@@ -834,6 +827,16 @@ int _glfwInitWayland(void)
createKeyTables();
_glfw.wl.keyRepeatTimerfd =
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
if (_glfw.wl.keyRepeatTimerfd == -1)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to create timerfd: %s",
strerror(errno));
return GLFW_FALSE;
}
_glfw.wl.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!_glfw.wl.xkb.context)
{