# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1355384910 0 # Node ID 2fe7fca612364f0792aa8b64fb0d2887477cb260 # Parent 123d1a900f54d253abe6babdd13f56e386449a7d Added support for trapping the Mac Quit handler by using DW_DESKTOP as the window handle to dw_signal_connect(). diff -r 123d1a900f54 -r 2fe7fca61236 mac/dw.m --- a/mac/dw.m Tue Nov 20 20:42:06 2012 +0000 +++ b/mac/dw.m Thu Dec 13 07:48:30 2012 +0000 @@ -869,6 +869,25 @@ -(BOOL)acceptsFirstResponder { return YES; } @end +/* Subclass for the application class */ +@interface DWAppDel : NSObject +#ifdef BUILDING_FOR_SNOW_LEOPARD + +#endif +{ +} +-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end + +@implementation DWAppDel +-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender +{ + if(_event_handler(sender, nil, 6) > 0) + return NSTerminateCancel; + return NSTerminateNow; +} +@end + /* Subclass for a top-level window */ @interface DWView : DWBox #ifdef BUILDING_FOR_SNOW_LEOPARD @@ -9885,6 +9904,12 @@ void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) { ULONG message = 0, msgid = 0; + + /* Handle special case of application delete signal */ + if(!window && signame && strcmp(signame, DW_SIGNAL_DELETE) == 0) + { + window = DWApp; + } if(window && signame && sigfunc) { @@ -10756,6 +10781,8 @@ setlocale(LC_ALL, lang && strstr(lang, ".UTF-8") ? lang : "UTF-8"); /* Create the application object */ DWApp = [NSApplication sharedApplication]; + DWAppDel *del = [[DWAppDel alloc] init]; + [DWApp setDelegate:del]; /* Create object for handling timers */ DWHandler = [[DWTimerHandler alloc] init]; /* If we aren't using garbage collection we need autorelease pools */