From bd9f6ca9ff0e9509f49980fc1b70837f54b6f244 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sat, 31 Oct 2026 11:13:46 -0400
Subject: [PATCH] x11: Process all modifier keys when reconciling
Modifiers must be processed, even if the key state hasn't changed, to properly rebuild the modifier state.
---
src/video/x11/SDL_x11events.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index b975edb5cb7fc..1fd6f70ba8c61 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -562,7 +562,7 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this)
const bool x11KeyPressed = (keys[keycode / 8] & (1 << (keycode % 8))) != 0;
const bool sdlKeyPressed = keystate[scancode];
- if (x11KeyPressed && !sdlKeyPressed) {
+ if (x11KeyPressed) {
// Only update modifier state for keys that are pressed in another application
switch (SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false)) {
case SDLK_LCTRL:
@@ -576,14 +576,18 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this)
case SDLK_MODE:
case SDLK_LEVEL5_SHIFT:
X11_HandleModifierKeys(videodata, scancode, true);
- SDL_SendKeyboardKeyIgnoreModifiers(0, SDL_GLOBAL_KEYBOARD_ID, keycode, scancode, true);
+ if (!sdlKeyPressed) {
+ SDL_SendKeyboardKeyIgnoreModifiers(0, SDL_GLOBAL_KEYBOARD_ID, keycode, scancode, true);
+ }
break;
default:
break;
}
- } else if (!x11KeyPressed && sdlKeyPressed) {
+ } else {
X11_HandleModifierKeys(videodata, scancode, false);
- SDL_SendKeyboardKeyIgnoreModifiers(0, SDL_GLOBAL_KEYBOARD_ID, keycode, scancode, false);
+ if (sdlKeyPressed) {
+ SDL_SendKeyboardKeyIgnoreModifiers(0, SDL_GLOBAL_KEYBOARD_ID, keycode, scancode, false);
+ }
}
}