fix close window notif and unused vars (#10)

It wasn't detecting that the window was closed when I closed it by
clicking the red X button. As a result, the window would close, but
mfb_update() didn't return -1, so the program kept running.

This was fixed by listening to the willClose event and using it to set a
flag. I'm not sure if this is the best way to do it, I really know
nothing about OSX/Cocoa.

Also, I fixed a few unused varible warnings. And warnings related to
NSUInteger not matching the expected signature with NSWindowStyleMask.
This commit is contained in:
Nicolas Guillemot
2017-01-24 12:18:06 -08:00
committed by Daniel Collin
parent b0f1590fc5
commit a5e8dd4e2e
4 changed files with 27 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)windowStyle
styleMask:(NSWindowStyleMask)windowStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)deferCreation
{
@@ -31,6 +31,14 @@
selector:@selector(mainWindowChanged:)
name:NSWindowDidResignMainNotification
object:self];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(willClose)
name:NSWindowWillCloseNotification
object:self];
closed = false;
}
return self;
}
@@ -65,6 +73,7 @@
- (void)mainWindowChanged:(NSNotification *)aNotification
{
(void)aNotification;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -128,9 +137,17 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ (NSRect)frameRectForContentRect:(NSRect)windowContentRect styleMask:(NSUInteger)windowStyle
+ (NSRect)frameRectForContentRect:(NSRect)windowContentRect styleMask:(NSWindowStyleMask)windowStyle
{
(void)windowStyle;
return NSInsetRect(windowContentRect, 0, 0);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)willClose
{
closed = true;
}
@end