diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index a219e29ac..b3baa8378 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -36,6 +36,22 @@ #define UsrActivity 1 #endif +@interface SDLApplication : NSApplication + +- (void)terminate:(id)sender; + +@end + +@implementation SDLApplication + +// Override terminate to handle Quit and System Shutdown smoothly. +- (void)terminate:(id)sender +{ + SDL_SendQuit(); +} + +@end // SDLApplication + /* setAppleMenu disappeared from the headers in 10.4 */ @interface NSApplication(NSAppleMenu) - (void)setAppleMenu:(NSMenu *)menu; @@ -71,12 +87,6 @@ [super dealloc]; } -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender -{ - SDL_SendQuit(); - return NSTerminateCancel; -} - - (void)focusSomeWindow:(NSNotification *)aNotification { /* HACK: Ignore the first call. The application gets a @@ -255,7 +265,7 @@ Cocoa_RegisterApp(void) pool = [[NSAutoreleasePool alloc] init]; if (NSApp == nil) { - [NSApplication sharedApplication]; + [SDLApplication sharedApplication]; if ([NSApp mainMenu] == nil) { CreateApplicationMenus();