From 507bdb6824719726a90cd90fc684f36a978eaf93 Mon Sep 17 00:00:00 2001 From: kappaOne Date: Sun, 10 Nov 2013 02:14:55 +0000 Subject: [PATCH] Finalise OS X Fullscreen Mode API behaviour --- src/native/macosx/org_lwjgl_opengl_Display.m | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m index 02419937..7c0d92c4 100644 --- a/src/native/macosx/org_lwjgl_opengl_Display.m +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -132,7 +132,7 @@ static NSUInteger lastModifierFlags = 0; // Inform the view of its parent window info; [window_info->view setParent:window_info]; - if (window_info->enableFullscreenModeAPI) { + if (window_info->enableFullscreenModeAPI && window_info->resizable) { // manually create OS X 10.7+ mask to allow compilation on previous OS X versions NSUInteger NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7; [window_info->window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; @@ -141,9 +141,6 @@ static NSUInteger lastModifierFlags = 0; [window_info->window makeFirstResponder:window_info->view]; [window_info->window setInitialFirstResponder:window_info->view]; [window_info->window makeKeyAndOrderFront:[NSApplication sharedApplication]]; - - // call method using runtime selector as its a 10.7+ api and allows compiling on older SDK's - //[window_info->window performSelector:NSSelectorFromString(@"toggleFullScreen:") withObject:nil]; } + (void) destroyWindow { @@ -599,6 +596,24 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetResizable(JNIEnv style_mask &= ~NSResizableWindowMask; } [window_info->window setStyleMask:style_mask]; + + if (window_info->enableFullscreenModeAPI) { + if (resizable) { + // manually create OS X 10.7+ mask to allow compilation on previous OS X versions + NSUInteger NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7; + [window_info->window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } + else { + // manually create OS X 10.7+ mask to allow compilation on previous OS X versions + NSUInteger NSFullScreenWindowMask = 1 << 14; + // on disabling resizing exit fullscreen mode exit otherwise will be stuck in it + if ((style_mask & NSFullScreenWindowMask) == NSFullScreenWindowMask) { + // call method using runtime selector as its a 10.7+ api and allows compiling on older SDK's + [window_info->window performSelector:NSSelectorFromString(@"toggleFullScreen:") withObject:nil]; + } + [window_info->window setCollectionBehavior:NSWindowCollectionBehaviorDefault]; + } + } } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetX(JNIEnv *env, jobject this, jobject window_handle) {