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).
This commit is contained in:
Jørgen P. Tjernø 2013-07-15 11:58:49 -07:00
parent 7aa0cf9eaa
commit 074edba0c1

View file

@ -43,6 +43,7 @@
@interface SDLAppDelegate : NSObject @interface SDLAppDelegate : NSObject
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
- (void)applicationDidBecomeActive:(NSNotification *)aNotification;
@end @end
@implementation SDLAppDelegate : NSObject @implementation SDLAppDelegate : NSObject
@ -52,6 +53,33 @@
return NSTerminateCancel; 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 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{ {
return (BOOL)SDL_SendDropFile([filename UTF8String]); return (BOOL)SDL_SendDropFile([filename UTF8String]);