Implement initial support for the OS X 10.7+ fullscreen mode API,
currently enabled using the VM parameter org.lwjgl.opengl.Display.enableOSXFullscreenModeAPI
This commit is contained in:
parent
675838f692
commit
75fe62bbea
|
@ -96,7 +96,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
|
||||
}
|
||||
|
||||
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
|
||||
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, boolean enableFullscreenModeAPI, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
|
||||
|
||||
private native Object nGetCurrentDisplayMode();
|
||||
|
||||
|
@ -131,6 +131,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
boolean resizable = Display.isResizable();
|
||||
boolean parented = (parent != null) && !fullscreen;
|
||||
|
||||
// OS X fullscreen mode API is only available on OS X 10.7+
|
||||
boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
|
||||
Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableOSXFullscreenModeAPI");
|
||||
|
||||
if (parented) this.canvas = parent;
|
||||
else this.canvas = null;
|
||||
|
||||
|
@ -145,7 +149,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
|
||||
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
|
||||
fullscreen, isUndecorated(), resizable,
|
||||
parented, peer_handle, window_handle);
|
||||
parented, enableFullscreenModeAPI, peer_handle, window_handle);
|
||||
|
||||
if (fullscreen) {
|
||||
// when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
|
||||
|
|
|
@ -80,6 +80,7 @@ typedef struct {
|
|||
jboolean undecorated;
|
||||
jboolean resizable;
|
||||
jboolean parented;
|
||||
jboolean enableFullscreenModeAPI;
|
||||
|
||||
jboolean resized;
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ static NSUInteger lastModifierFlags = 0;
|
|||
// enter fullscreen mode
|
||||
[window_info->view enterFullScreenMode: [NSScreen mainScreen] withOptions: nil ];
|
||||
window_info->window = [window_info->view window];
|
||||
|
||||
|
||||
// adjust the NSView bounds to correct mouse coordinates in fullscreen
|
||||
NSSize windowSize = [window_info->window frame].size;
|
||||
NSSize newBounds = NSMakeSize(windowSize.width/width*windowSize.width, windowSize.height/height*windowSize.height);
|
||||
|
@ -132,9 +132,18 @@ static NSUInteger lastModifierFlags = 0;
|
|||
// Inform the view of its parent window info;
|
||||
[window_info->view setParent:window_info];
|
||||
|
||||
if (window_info->enableFullscreenModeAPI) {
|
||||
// manually create OS X 10.7+ mask to allow compilation on previous OS X versions
|
||||
NSUInteger NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7;
|
||||
[window_info->window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
}
|
||||
|
||||
[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 {
|
||||
|
@ -616,7 +625,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetTitle(JNIEnv *env
|
|||
[window_info->window performSelectorOnMainThread:@selector(setTitle:) withObject:title waitUntilDone:NO];
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jboolean parented, jobject peer_info_handle, jobject window_handle) {
|
||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jboolean parented, jboolean enableFullscreenModeAPI, jobject peer_info_handle, jobject window_handle) {
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
@ -627,6 +636,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
|
|||
window_info->fullscreen = fullscreen;
|
||||
window_info->undecorated = undecorated;
|
||||
window_info->parented = parented;
|
||||
window_info->enableFullscreenModeAPI = enableFullscreenModeAPI;
|
||||
|
||||
return window_handle;
|
||||
}
|
||||
|
@ -645,6 +655,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
|
|||
window_info->undecorated = undecorated;
|
||||
window_info->resizable = resizable;
|
||||
window_info->parented = parented;
|
||||
window_info->enableFullscreenModeAPI = enableFullscreenModeAPI;
|
||||
|
||||
peer_info->window_info = window_info;
|
||||
peer_info->isWindowed = true;
|
||||
|
|
Loading…
Reference in New Issue