From 51fa076fdc56c3d9da92bf2f25bd78a23b80362e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 14 Jan 2025 23:28:31 -0800 Subject: [PATCH] Don't send normal keyboard events if no application window has focus This can happen if all the windows shown have the SDL_WINDOW_NOT_FOCUSABLE flag. We'll still accept modifier state changes though, so you can do Control-click actions. --- src/video/cocoa/SDL_cocoakeyboard.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 19ee593201..f73572da59 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -476,7 +476,7 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event) [data.fieldEdit setPendingKey:scancode scancode:code timestamp:Cocoa_GetEventTimestamp([event timestamp])]; [data.fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]]; [data.fieldEdit sendPendingKey]; - } else { + } else if (SDL_GetKeyboardFocus()) { SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), SDL_DEFAULT_KEYBOARD_ID, scancode, code, true); } break;