wayland: Synthesize repeated keys after processing events

Otherwise, long delays between pumping events can result in repeating keys that were already lifted some time ago.
This commit is contained in:
Frank Praznik
2025-10-24 15:46:50 -04:00
parent 51b401d418
commit 537e92b158

View File

@@ -599,16 +599,6 @@ void Wayland_PumpEvents(SDL_VideoDevice *_this)
}
#endif
// Synthesize key repeat events.
wl_list_for_each (seat, &d->seat_list, link) {
if (keyboard_repeat_is_set(&seat->keyboard.repeat)) {
Wayland_SeatSetKeymap(seat);
const Uint64 elapsed = SDL_GetTicksNS() - seat->keyboard.repeat.sdl_press_time_ns;
keyboard_repeat_handle(&seat->keyboard.repeat, elapsed);
}
}
#ifdef HAVE_LIBDECOR_H
if (d->shell.libdecor) {
libdecor_dispatch(d->shell.libdecor, 0);
@@ -661,6 +651,18 @@ void Wayland_PumpEvents(SDL_VideoDevice *_this)
ret = WAYLAND_wl_display_dispatch_pending(d->display);
}
if (ret >= 0) {
// Synthesize key repeat events.
wl_list_for_each (seat, &d->seat_list, link) {
if (keyboard_repeat_is_set(&seat->keyboard.repeat)) {
Wayland_SeatSetKeymap(seat);
const Uint64 elapsed = SDL_GetTicksNS() - seat->keyboard.repeat.sdl_press_time_ns;
keyboard_repeat_handle(&seat->keyboard.repeat, elapsed);
}
}
}
connection_error:
if (ret < 0 && !d->display_disconnected) {
/* Something has failed with the Wayland connection -- for example,