Mercurial > dwindows
changeset 1843:2fe7fca61236
Added support for trapping the Mac Quit handler by using DW_DESKTOP as
the window handle to dw_signal_connect().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 13 Dec 2012 07:48:30 +0000 |
parents | 123d1a900f54 |
children | 1558f5e14f83 |
files | mac/dw.m |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 +<NSApplicationDelegate> +#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 */