Mac: Bring back FS windows when appropriate
authorJørgen P. Tjernø
Mon, 15 Jul 2013 11:58:49 -0700
changeset 74663416e8cfbaf0
parent 7465 1bcf7aac5623
child 7467 998579383ced
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
     1.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Mon Jul 15 11:58:45 2013 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Mon Jul 15 11:58:49 2013 -0700
     1.3 @@ -43,6 +43,7 @@
     1.4  
     1.5  @interface SDLAppDelegate : NSObject
     1.6  - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
     1.7 +- (void)applicationDidBecomeActive:(NSNotification *)aNotification;
     1.8  @end
     1.9  
    1.10  @implementation SDLAppDelegate : NSObject
    1.11 @@ -52,6 +53,33 @@
    1.12      return NSTerminateCancel;
    1.13  }
    1.14  
    1.15 +- (void)applicationDidBecomeActive:(NSNotification *)aNotification
    1.16 +{
    1.17 +    SDL_VideoDevice *device = SDL_GetVideoDevice();
    1.18 +    if (device && device->windows)
    1.19 +    {
    1.20 +        SDL_Window *window = device->windows;
    1.21 +        int i;
    1.22 +        for (i = 0; i < device->num_displays; ++i)
    1.23 +        {
    1.24 +            SDL_Window *fullscreen_window = device->displays[i].fullscreen_window;
    1.25 +            if (fullscreen_window)
    1.26 +            {
    1.27 +                if (fullscreen_window->flags & SDL_WINDOW_MINIMIZED) {
    1.28 +                    SDL_RestoreWindow(fullscreen_window);
    1.29 +                }
    1.30 +                return;
    1.31 +            }
    1.32 +        }
    1.33 +
    1.34 +        if (window->flags & SDL_WINDOW_MINIMIZED) {
    1.35 +            SDL_RestoreWindow(window);
    1.36 +        } else {
    1.37 +            SDL_RaiseWindow(window);
    1.38 +        }
    1.39 +    }
    1.40 +}
    1.41 +
    1.42  - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
    1.43  {
    1.44      return (BOOL)SDL_SendDropFile([filename UTF8String]);