|
@@ -42,12 +42,11 @@
|
|
@end
|
|
@end
|
|
|
|
|
|
@interface SDLAppDelegate : NSObject {
|
|
@interface SDLAppDelegate : NSObject {
|
|
|
|
+@public
|
|
BOOL seenFirstActivate;
|
|
BOOL seenFirstActivate;
|
|
}
|
|
}
|
|
|
|
|
|
- (id)init;
|
|
- (id)init;
|
|
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
|
|
|
|
-- (void)applicationDidBecomeActive:(NSNotification *)aNotification;
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
@implementation SDLAppDelegate : NSObject
|
|
@implementation SDLAppDelegate : NSObject
|
|
@@ -57,18 +56,28 @@
|
|
|
|
|
|
if (self) {
|
|
if (self) {
|
|
seenFirstActivate = NO;
|
|
seenFirstActivate = NO;
|
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
+ selector:@selector(focusSomeWindow:)
|
|
|
|
+ name:NSApplicationDidBecomeActiveNotification
|
|
|
|
+ object:nil];
|
|
}
|
|
}
|
|
|
|
|
|
return self;
|
|
return self;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)dealloc
|
|
|
|
+{
|
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
+ [super dealloc];
|
|
|
|
+}
|
|
|
|
+
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
|
{
|
|
{
|
|
SDL_SendQuit();
|
|
SDL_SendQuit();
|
|
return NSTerminateCancel;
|
|
return NSTerminateCancel;
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
|
|
|
|
|
+- (void)focusSomeWindow:(NSNotification *)aNotification
|
|
{
|
|
{
|
|
/* HACK: Ignore the first call. The application gets a
|
|
/* HACK: Ignore the first call. The application gets a
|
|
* applicationDidBecomeActive: a little bit after the first window is
|
|
* applicationDidBecomeActive: a little bit after the first window is
|
|
@@ -111,6 +120,8 @@
|
|
}
|
|
}
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
+static SDLAppDelegate *appDelegate = nil;
|
|
|
|
+
|
|
static NSString *
|
|
static NSString *
|
|
GetApplicationName(void)
|
|
GetApplicationName(void)
|
|
{
|
|
{
|
|
@@ -235,8 +246,17 @@ Cocoa_RegisterApp(void)
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
|
|
|
|
|
}
|
|
}
|
|
- if (NSApp && ![NSApp delegate]) {
|
|
|
|
- [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
|
|
|
|
|
|
+ if (NSApp && !appDelegate) {
|
|
|
|
+ appDelegate = [[SDLAppDelegate alloc] init];
|
|
|
|
+
|
|
|
|
+ /* If someone else has an app delegate, it means we can't turn a
|
|
|
|
+ * termination into SDL_Quit, and we can't handle application:openFile:
|
|
|
|
+ */
|
|
|
|
+ if (![NSApp delegate]) {
|
|
|
|
+ [NSApp setDelegate:appDelegate];
|
|
|
|
+ } else {
|
|
|
|
+ appDelegate->seenFirstActivate = YES;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
[pool release];
|
|
[pool release];
|
|
}
|
|
}
|