diff --git a/src/macosx/MacMiniFB.m b/src/macosx/MacMiniFB.m index 9cefa56..a0fbb68 100644 --- a/src/macosx/MacMiniFB.m +++ b/src/macosx/MacMiniFB.m @@ -2,14 +2,14 @@ #include "OSXWindow.h" #include #include -#include +#include "MiniFB.h" /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void* g_updateBuffer = 0; int g_width = 0; int g_height = 0; -static NSWindow* window_; +static OSXWindow* window_; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -83,6 +83,9 @@ static int updateEvents() } [pool release]; + if (window_->closed) + state = -1; + return state; } diff --git a/src/macosx/OSXWindow.h b/src/macosx/OSXWindow.h index 5314f9c..05eb51e 100644 --- a/src/macosx/OSXWindow.h +++ b/src/macosx/OSXWindow.h @@ -5,6 +5,7 @@ @interface OSXWindow : NSWindow { NSView* childContentView; + @public bool closed; } @end diff --git a/src/macosx/OSXWindow.m b/src/macosx/OSXWindow.m index a910e10..e1107d1 100644 --- a/src/macosx/OSXWindow.m +++ b/src/macosx/OSXWindow.m @@ -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 diff --git a/src/macosx/OSXWindowFrameView.m b/src/macosx/OSXWindowFrameView.m index 1f01a41..0961d41 100644 --- a/src/macosx/OSXWindowFrameView.m +++ b/src/macosx/OSXWindowFrameView.m @@ -27,6 +27,8 @@ extern int g_height; - (void)drawRect:(NSRect)rect { + (void)rect; + if (!g_updateBuffer) return;