summaryrefslogtreecommitdiff
path: root/new/window_darwin.m
diff options
context:
space:
mode:
Diffstat (limited to 'new/window_darwin.m')
-rw-r--r--new/window_darwin.m11
1 files changed, 7 insertions, 4 deletions
diff --git a/new/window_darwin.m b/new/window_darwin.m
index 4469690..1a60f8b 100644
--- a/new/window_darwin.m
+++ b/new/window_darwin.m
@@ -1,8 +1,9 @@
// 6 april 2015
#include "ui_darwin.h"
-@interface uiWindowDelegate : NSWindowDelegate
-@property void (*onClosing)(uiWindow *, void *);
+@interface uiWindowDelegate : NSObject <NSWindowDelegate>
+@property uiWindow *w;
+@property int (*onClosing)(uiWindow *, void *);
@property void *onClosingData;
@end
@@ -12,7 +13,7 @@
- (BOOL)windowShouldClose:(id)win
{
// return exact constants to be safe
- if ((*(self.onClosing))(self.onClosingData))
+ if ((*(self.onClosing))(self.w, self.onClosingData))
return YES;
return NO;
}
@@ -39,9 +40,11 @@ uiWindow *uiNewWindow(char *title, int width, int height)
styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
backing:NSBackingStoreBuffered
defer:YES];
+ [w->w setTitle:toNSString(title)];
// TODO substitutions
w->d = [uiWindowDelegate new];
+ w->d.w = w;
w->d.onClosing = defaultOnClosing;
[w->w setDelegate:w->d];
@@ -71,7 +74,7 @@ void uiWindowHide(uiWindow *w)
[w->w orderOut:w->w];
}
-void uiWindowOnClosing(uiWindow *w, int (*)(uiWindow *f, void *), void *data)
+void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data)
{
w->d.onClosing = f;
w->d.onClosingData = data;