From 074edba0c11fcde0ba0e0ec903637ca6a54e76dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 15 Jul 2013 11:58:49 -0700 Subject: [PATCH] Mac: Bring back FS windows when appropriate This automatically restores FS windows when the application is made active (Cmd-Tab, you click the Dock icon, or you launch the .app again). --- src/video/cocoa/SDL_cocoaevents.m | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index e952a9e9f..19bd6f7fc 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -43,6 +43,7 @@ @interface SDLAppDelegate : NSObject - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +- (void)applicationDidBecomeActive:(NSNotification *)aNotification; @end @implementation SDLAppDelegate : NSObject @@ -52,6 +53,33 @@ return NSTerminateCancel; } +- (void)applicationDidBecomeActive:(NSNotification *)aNotification +{ + SDL_VideoDevice *device = SDL_GetVideoDevice(); + if (device && device->windows) + { + SDL_Window *window = device->windows; + int i; + for (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) { + SDL_RestoreWindow(fullscreen_window); + } + return; + } + } + + if (window->flags & SDL_WINDOW_MINIMIZED) { + SDL_RestoreWindow(window); + } else { + SDL_RaiseWindow(window); + } + } +} + - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { return (BOOL)SDL_SendDropFile([filename UTF8String]);