Skip to content

Commit 537e92b

Browse files
committed
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.
1 parent 51b401d commit 537e92b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/video/wayland/SDL_waylandevents.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,6 @@ void Wayland_PumpEvents(SDL_VideoDevice *_this)
599599
}
600600
#endif
601601

602-
// Synthesize key repeat events.
603-
wl_list_for_each (seat, &d->seat_list, link) {
604-
if (keyboard_repeat_is_set(&seat->keyboard.repeat)) {
605-
Wayland_SeatSetKeymap(seat);
606-
607-
const Uint64 elapsed = SDL_GetTicksNS() - seat->keyboard.repeat.sdl_press_time_ns;
608-
keyboard_repeat_handle(&seat->keyboard.repeat, elapsed);
609-
}
610-
}
611-
612602
#ifdef HAVE_LIBDECOR_H
613603
if (d->shell.libdecor) {
614604
libdecor_dispatch(d->shell.libdecor, 0);
@@ -661,6 +651,18 @@ void Wayland_PumpEvents(SDL_VideoDevice *_this)
661651
ret = WAYLAND_wl_display_dispatch_pending(d->display);
662652
}
663653

654+
if (ret >= 0) {
655+
// Synthesize key repeat events.
656+
wl_list_for_each (seat, &d->seat_list, link) {
657+
if (keyboard_repeat_is_set(&seat->keyboard.repeat)) {
658+
Wayland_SeatSetKeymap(seat);
659+
660+
const Uint64 elapsed = SDL_GetTicksNS() - seat->keyboard.repeat.sdl_press_time_ns;
661+
keyboard_repeat_handle(&seat->keyboard.repeat, elapsed);
662+
}
663+
}
664+
}
665+
664666
connection_error:
665667
if (ret < 0 && !d->display_disconnected) {
666668
/* Something has failed with the Wayland connection -- for example,

0 commit comments

Comments
 (0)