From bce2a336d2fb12db10ead111fc1420732c35afb5 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 20 Sep 2025 18:57:22 -0700 Subject: [PATCH] Use the default window focus behavior on macOS We had to work around odd behavior in really old versions of macOS, but the current behavior is great. Fixes https://github.com/libsdl-org/SDL/issues/3954 --- src/video/cocoa/SDL_cocoaevents.m | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index fd178b8dac..64b2798c1e 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -261,11 +261,10 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) return; } + // Restore any fullscreen window device = SDL_GetVideoDevice(); if (device && device->windows) { - SDL_Window *window = device->windows; - int i; - for (i = 0; i < device->num_displays; ++i) { + for (int i = 0; i < device->num_displays; ++i) { SDL_Window *fullscreen_window = device->displays[i]->fullscreen_window; if (fullscreen_window) { if (fullscreen_window->flags & SDL_WINDOW_MINIMIZED) { @@ -274,12 +273,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) return; } } - - if (window->flags & SDL_WINDOW_MINIMIZED) { - SDL_RestoreWindow(window); - } else { - SDL_RaiseWindow(window); - } } } @@ -370,9 +363,9 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) - (IBAction)menu:(id)sender { - SDL_TrayEntry *entry = [[sender representedObject] pointerValue]; + SDL_TrayEntry *entry = [[sender representedObject] pointerValue]; - SDL_ClickTrayEntry(entry); + SDL_ClickTrayEntry(entry); } @end