+#import <AppKit/NSApplication.h>
#import <AppKit/NSWindow.h>
#import <CoreFoundation/CFArray.h>
#include "cocoadisplay.h"
#include "cocoawindow.h"
-@interface WindowDelegate: NSObject <NSWindowDelegate>
+@interface MspWindow: NSWindow {
+ int dummy_member;
+}
-- (void)windowWillClose:(NSNotification *)notification;
+- (BOOL)windowShouldClose:(id)sender;
+- (void)keyDown:(NSEvent *)event;
@end
{
CocoaDisplay *display;
__strong NSWindow *window;
- __strong WindowDelegate *delegate;
NSUInteger style;
};
CFMutableDictionaryRef windows = NULL;
-CFMutableArrayRef event_queue = NULL;
CocoaWindow *create_window(CocoaDisplay *display, unsigned width, unsigned height, bool fullscreen, bool resizable)
{
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];
wrapper->window = window;
wrapper->style = style;
- wrapper->delegate = [[WindowDelegate alloc] init];
- [window setDelegate:wrapper->delegate];
-
if(!windows)
windows = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
CFDictionaryAddValue(windows, window, wrapper);
}
[window->window release];
- [window->delegate release];
free(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