diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-08 17:43:50 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-08 17:44:08 -0400 |
| commit | 44811e5351c13917f400fe5eed0145e224f0c43e (patch) | |
| tree | a06e521b64197002196737f09c0f781c38654fb2 /redo/window_darwin.m | |
| parent | edd81e2e48d4e2c14820370dd5829fecaf19d387 (diff) | |
Implemented window closing on Mac OS X. This drops the "single delegate object for everything" setup but keeping that map and holding its lock is already meh so.
Diffstat (limited to 'redo/window_darwin.m')
| -rw-r--r-- | redo/window_darwin.m | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/redo/window_darwin.m b/redo/window_darwin.m index 870243c..d0b1347 100644 --- a/redo/window_darwin.m +++ b/redo/window_darwin.m @@ -6,6 +6,22 @@ #define toNSWindow(x) ((NSWindow *) (x)) +// TODO why do I need the explicit interface specification? +@interface goWindowDelegate : NSObject <NSWindowDelegate> { +@public + void *gowin; +} +@end + +@implementation goWindowDelegate + +- (BOOL)windowShouldClose:(id)win +{ + return windowClosing(self->gowin); +} + +@end + id newWindow(intptr_t width, intptr_t height) { return [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height) @@ -14,9 +30,13 @@ id newWindow(intptr_t width, intptr_t height) defer:YES]; } -void windowSetAppDelegate(id win) +void windowSetDelegate(id win, void *w) { - [toNSWindow(win) setDelegate:getAppDelegate()]; + goWindowDelegate *d; + + d = [goWindowDelegate new]; + d->gowin = w; + [toNSWindow(win) setDelegate:d]; } const char *windowTitle(id win) |
