Mac: Handle SDL_CreateWindow with SDL_WINDOW_MINIMZED.
This fixes bug #1446. You can now create a window with SDL_CreateWindow(..., SDL_WINDOW_MINIMIZED), and not have it immediately restore itself. It also changes SDL_RaiseWindow() to be a no-op on minimized or hidden windows, which is how it behaves on Windows.
This commit is contained in:
parent
5256d2e392
commit
3f15d37da2
2 changed files with 31 additions and 2 deletions
|
@ -41,12 +41,27 @@
|
|||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
@interface SDLAppDelegate : NSObject
|
||||
@interface SDLAppDelegate : NSObject {
|
||||
BOOL seenFirstActivate;
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification;
|
||||
@end
|
||||
|
||||
@implementation SDLAppDelegate : NSObject
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
seenFirstActivate = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
SDL_SendQuit();
|
||||
|
@ -55,6 +70,16 @@
|
|||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
{
|
||||
/* HACK: Ignore the first call. The application gets a
|
||||
* applicationDidBecomeActive: a little bit after the first window is
|
||||
* created, and if we don't ignore it, a window that has been created with
|
||||
* SDL_WINDOW_MINIZED will ~immediately be restored.
|
||||
*/
|
||||
if (!seenFirstActivate) {
|
||||
seenFirstActivate = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
if (device && device->windows)
|
||||
{
|
||||
|
|
|
@ -866,8 +866,12 @@ Cocoa_RaiseWindow(_THIS, SDL_Window * window)
|
|||
SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
|
||||
NSWindow *nswindow = windowData->nswindow;
|
||||
|
||||
// makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing
|
||||
// a minimized or hidden window, so check for that before showing it.
|
||||
[windowData->listener pauseVisibleObservation];
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
if (![nswindow isMiniaturized] && [nswindow isVisible]) {
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
[windowData->listener resumeVisibleObservation];
|
||||
|
||||
[pool release];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue