diff options
Diffstat (limited to 'new/window_darwin.m')
| -rw-r--r-- | new/window_darwin.m | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/new/window_darwin.m b/new/window_darwin.m index 795c2e0..8d582c3 100644 --- a/new/window_darwin.m +++ b/new/window_darwin.m @@ -4,6 +4,19 @@ // TODO // - showing on size +#ifdef uiLogAllocations +@interface loggingNSWindow : NSWindow +@end + +@implementation loggingNSWindow + +uiLogObjCClassAllocations + +@end +#else +#define loggingNSWindow NSWindow +#endif + @interface uiWindowDelegate : NSObject <NSWindowDelegate> @property uiWindow *w; @property int (*onClosing)(uiWindow *, void *); @@ -14,7 +27,6 @@ uiLogObjCClassAllocations -// TODO will this *destroy* the window? - (BOOL)windowShouldClose:(id)win { // return exact constants to be safe @@ -23,6 +35,11 @@ uiLogObjCClassAllocations return NO; } +- (void)windowWillClose:(NSNotification *)note +{ + [self release]; +} + @end struct uiWindow { @@ -43,13 +60,16 @@ uiWindow *uiNewWindow(char *title, int width, int height) w = uiNew(uiWindow); - w->w = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height) + w->w = [[loggingNSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height) styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask) backing:NSBackingStoreBuffered defer:YES]; [w->w setTitle:toNSString(title)]; // TODO substitutions + // this is what will destroy the window on close + [w->w setReleasedWhenClosed:YES]; + w->container = [[uiContainer alloc] initWithFrame:NSZeroRect]; [w->w setContentView:((NSView *) w->container)]; @@ -63,8 +83,7 @@ uiWindow *uiNewWindow(char *title, int width, int height) void uiWindowDestroy(uiWindow *w) { - // TODO - // TODO will w->d be destroyed? + [w->w close]; } uintptr_t uiWindowHandle(uiWindow *w) |
