X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fcocoa%2Fcocoawindow.m;h=11181269b5faa9432e09d55644bbb4f337cb7d98;hb=97707c9f57234bf7992bac03bd52cb3fdd00fcfa;hp=692952002f7c6be6f5d60be10266ba2d5e03b58a;hpb=ad7b7bd9c61fc61e5ae5b8434d0d687b63a755c7;p=libs%2Fgui.git diff --git a/source/graphics/cocoa/cocoawindow.m b/source/graphics/cocoa/cocoawindow.m index 6929520..1118126 100644 --- a/source/graphics/cocoa/cocoawindow.m +++ b/source/graphics/cocoa/cocoawindow.m @@ -1,11 +1,15 @@ +#import #import #import #include "cocoadisplay.h" #include "cocoawindow.h" -@interface WindowDelegate: NSObject +@interface MspWindow: NSWindow { + int dummy_member; +} -- (void)windowWillClose:(NSNotification *)notification; +- (BOOL)windowShouldClose:(id)sender; +- (void)keyDown:(NSEvent *)event; @end @@ -17,7 +21,6 @@ struct _CocoaWindow }; CFMutableDictionaryRef windows = NULL; -CFMutableArrayRef event_queue = NULL; CocoaWindow *create_window(CocoaDisplay *display, unsigned width, unsigned height, bool fullscreen, bool resizable) { @@ -25,7 +28,7 @@ CocoaWindow *create_window(CocoaDisplay *display, unsigned width, unsigned heigh NSUInteger style = NSTitledWindowMask|NSClosableWindowMask; if(resizable) style |= NSResizableWindowMask; - NSWindow *window = [NSWindow alloc]; + NSWindow *window = [MspWindow alloc]; window = [window initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO]; [window setAcceptsMouseMovedEvents:YES]; @@ -36,8 +39,6 @@ CocoaWindow *create_window(CocoaDisplay *display, unsigned width, unsigned heigh wrapper->window = window; wrapper->style = style; - [window setDelegate:[[WindowDelegate alloc] init]]; - if(!windows) windows = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); CFDictionaryAddValue(windows, window, wrapper); @@ -91,18 +92,26 @@ void hide_window(CocoaWindow *window) (void)window; } -@implementation WindowDelegate +@implementation MspWindow -- (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; +} + +- (void)keyDown:(NSEvent *)event +{ + // Eat the event to avoid beeping + (void)event; } @end