Commit 49b9e3470bc9f07cf666e92bbc7405696f2b2ed9

Sam Lantinga 2022-04-07T08:24:03

Only update modifier state for keys that are pressed in another application Fixes https://github.com/libsdl-org/SDL/issues/4432

diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index c96b900..2beb252 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -408,7 +408,22 @@ X11_ReconcileKeyboardState(_THIS)
         SDL_bool sdlKeyPressed = keyboardState[scancode] == SDL_PRESSED;
 
         if (x11KeyPressed && !sdlKeyPressed) {
-            SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+            /* Only update modifier state for keys that are pressed in another application */
+            switch (SDL_GetKeyFromScancode(scancode)) {
+            case SDLK_LCTRL:
+            case SDLK_RCTRL:
+            case SDLK_LSHIFT:
+            case SDLK_RSHIFT:
+            case SDLK_LALT:
+            case SDLK_RALT:
+            case SDLK_LGUI:
+            case SDLK_RGUI:
+            case SDLK_MODE:
+                SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+                break;
+            default:
+                break;
+            }
         } else if (!x11KeyPressed && sdlKeyPressed) {
             SDL_SendKeyboardKey(SDL_RELEASED, scancode);
         }