From e579fd0f1d387869092b953b0b37a69663dc711c Mon Sep 17 00:00:00 2001 From: awsms <48278661+awsms@users.noreply.github.com> Date: Fri, 6 Mar 2026 08:08:00 +0100 Subject: [PATCH] sdl: ignore synthetic keyup events during key repeat On the SDL backend, holding a key can generate KEYUP events even while the key is still physically held. Gamescope already ignores repeated KEYDOWN events, but these KEYUPs were still forwarded to wlserver, causing spurious release notifications. Filter SDL_KEYUP by checking SDL_GetKeyboardState(): if SDL still reports the scancode as pressed, treat the KEYUP as synthetic repeat noise and drop it. --- src/Backends/SDLBackend.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Backends/SDLBackend.cpp b/src/Backends/SDLBackend.cpp index 87bde7e2f1..196a8b33cc 100644 --- a/src/Backends/SDLBackend.cpp +++ b/src/Backends/SDLBackend.cpp @@ -802,6 +802,18 @@ namespace gamescope if ( event.key.repeat ) break; + // Ignore synthetic repeat KEYUPs when SDL still reports the key down. + if ( event.type == SDL_KEYUP ) + { + const uint8_t *pKeyboardState = SDL_GetKeyboardState( nullptr ); + SDL_Scancode scancode = event.key.keysym.scancode; + if ( pKeyboardState && + scancode >= 0 && + scancode < SDL_NUM_SCANCODES && + pKeyboardState[ scancode ] ) + break; + } + wlserver_lock(); wlserver_key( key, event.type == SDL_KEYDOWN, fake_timestamp ); wlserver_unlock();