mirror of https://github.com/encounter/SDL.git
Fixed bug 2347 - On OSX, an SDL app prevents system shutdown.
Tim McDaniel On OSX, an SDL app forces a system shutdown to be cancelled. This happens because [SDLAppDelegate applicationShouldTerminate] returns NSTerminateCancel. A better approach is to subclass NSApplication and override terminate to do nothing except call SDL_SendQuit. In response to a system shutdown notification, this allows the normal SDL Quit event processing to occur, and if the app then terminates, system shutdown occurs normally. Please see the attached patch, based on SDL 2.0.1.
This commit is contained in:
parent
b80f4f9e50
commit
6bb2f2ef8d
|
@ -36,6 +36,22 @@
|
||||||
#define UsrActivity 1
|
#define UsrActivity 1
|
||||||
#endif
|
#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 */
|
/* setAppleMenu disappeared from the headers in 10.4 */
|
||||||
@interface NSApplication(NSAppleMenu)
|
@interface NSApplication(NSAppleMenu)
|
||||||
- (void)setAppleMenu:(NSMenu *)menu;
|
- (void)setAppleMenu:(NSMenu *)menu;
|
||||||
|
@ -71,12 +87,6 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
|
||||||
{
|
|
||||||
SDL_SendQuit();
|
|
||||||
return NSTerminateCancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)focusSomeWindow:(NSNotification *)aNotification
|
- (void)focusSomeWindow:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
/* HACK: Ignore the first call. The application gets a
|
/* HACK: Ignore the first call. The application gets a
|
||||||
|
@ -255,7 +265,7 @@ Cocoa_RegisterApp(void)
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
if (NSApp == nil) {
|
if (NSApp == nil) {
|
||||||
[NSApplication sharedApplication];
|
[SDLApplication sharedApplication];
|
||||||
|
|
||||||
if ([NSApp mainMenu] == nil) {
|
if ([NSApp mainMenu] == nil) {
|
||||||
CreateApplicationMenus();
|
CreateApplicationMenus();
|
||||||
|
|
Loading…
Reference in New Issue