X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fcocoa%2Fcocoawindow.m;h=cbf67222d7b91a60371a9180686220e52a997a2b;hb=b1dbcb05d3ec43654d78e2662ae22162561c8270;hp=692952002f7c6be6f5d60be10266ba2d5e03b58a;hpb=ad7b7bd9c61fc61e5ae5b8434d0d687b63a755c7;p=libs%2Fgui.git diff --git a/source/graphics/cocoa/cocoawindow.m b/source/graphics/cocoa/cocoawindow.m index 6929520..cbf6722 100644 --- a/source/graphics/cocoa/cocoawindow.m +++ b/source/graphics/cocoa/cocoawindow.m @@ -5,7 +5,7 @@ @interface WindowDelegate: NSObject -- (void)windowWillClose:(NSNotification *)notification; +- (BOOL)windowShouldClose:(id)sender; @end @@ -13,6 +13,7 @@ struct _CocoaWindow { CocoaDisplay *display; __strong NSWindow *window; + __strong WindowDelegate *delegate; NSUInteger style; }; @@ -36,7 +37,8 @@ CocoaWindow *create_window(CocoaDisplay *display, unsigned width, unsigned heigh wrapper->window = window; wrapper->style = style; - [window setDelegate:[[WindowDelegate alloc] init]]; + wrapper->delegate = [[WindowDelegate alloc] init]; + [window setDelegate:wrapper->delegate]; if(!windows) windows = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); @@ -55,6 +57,7 @@ void destroy_window(CocoaWindow *window) } [window->window release]; + [window->delegate release]; free(window); } @@ -93,16 +96,18 @@ void hide_window(CocoaWindow *window) @implementation WindowDelegate -- (void)windowWillClose:(NSNotification *)notification +- (BOOL)windowShouldClose:(id)sender { - CocoaWindow *window = lookup_window((NSWindow *)[notification object]); + CocoaWindow *window = lookup_window((NSWindow *)sender); if(window) { CocoaEvent event; event.any.type = WINDOW_CLOSED; event.any.window = window; queue_event(window->display, &event); + return NO; } + return YES; } @end