diff options
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 14 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java | 15 | ||||
-rw-r--r-- | src/newt/native/MacWindow.m | 63 | ||||
-rw-r--r-- | src/newt/native/NewtMacWindow.h | 8 | ||||
-rw-r--r-- | src/newt/native/NewtMacWindow.m | 47 |
5 files changed, 84 insertions, 63 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d62a19f44..21343b263 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -674,37 +674,37 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 != ( FLAG_CHANGE_PARENTING & flags) ) { sb.append("*"); } - sb.append("PARENT_"); + sb.append("PARENT "); sb.append(0 != ( FLAG_HAS_PARENT & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { sb.append("*"); } - sb.append("FS_"); + sb.append("FS "); sb.append(0 != ( FLAG_IS_FULLSCREEN & flags)); - sb.append("_span_"); + sb.append("[span "); sb.append(0 != ( FLAG_IS_FULLSCREEN_SPAN & flags)); - sb.append(", "); + sb.append("], "); if( 0 != ( FLAG_CHANGE_DECORATION & flags) ) { sb.append("*"); } - sb.append("UNDECOR_"); + sb.append("UNDECOR "); sb.append(0 != ( FLAG_IS_UNDECORATED & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_ALWAYSONTOP & flags) ) { sb.append("*"); } - sb.append("ALWAYSONTOP_"); + sb.append("ALWAYSONTOP "); sb.append(0 != ( FLAG_IS_ALWAYSONTOP & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { sb.append("*"); } - sb.append("VISIBLE_"); + sb.append("VISIBLE "); sb.append(0 != ( FLAG_IS_VISIBLE & flags)); sb.append("]"); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 7db3e2aab..641d7437c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -170,14 +170,20 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void requestFocusImpl(final boolean force) { + final boolean _isFullscreen = isFullscreen(); + final boolean _isOffscreenInstance = isOffscreenInstance; if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: requestFocusImpl(), isOffscreenInstance "+isOffscreenInstance); + System.err.println("MacWindow: requestFocusImpl(), isOffscreenInstance "+_isOffscreenInstance+", isFullscreen "+_isFullscreen); } - if(!isOffscreenInstance) { + if(!_isOffscreenInstance) { OSXUtil.RunOnMainThread(false, new Runnable() { @Override public void run() { requestFocus0(getWindowHandle(), force); + if(_isFullscreen) { + // 'NewtMacWindow::windowDidBecomeKey()' is not always called in fullscreen-mode! + focusChanged(false, true); + } } } ); } else { focusChanged(false, true); @@ -516,7 +522,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override public void run() { initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle); + isOpaque, visible && !offscreenInstance, surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWinHandle ? parentWinHandle : newWin); } else { @@ -534,8 +540,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native long createView0(int x, int y, int w, int h, boolean fullscreen); private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, long view); /** Must be called on Main-Thread */ - private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, boolean visible, long view); + private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, boolean opaque, boolean visible, long view); private native boolean lockSurface0(long window, long view); private native boolean unlockSurface0(long window, long view); /** Must be called on Main-Thread */ diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 3e8935787..30d3458ad 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -693,11 +693,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, - jboolean opaque, jboolean fullscreen, jboolean visible, jlong jview) + jboolean opaque, jboolean visible, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); NewtView* myView = (NewtView*) (intptr_t) jview ; + BOOL fullscreen = myWindow->isFullscreenWindow; DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, view %p (START)\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, @@ -824,8 +825,20 @@ NS_ENDHANDLER // [myView lockFocus]; // [myView unlockFocus]; + // Set the next responder to be the window so that we can forward + // right mouse button down events + [myView setNextResponder: myWindow]; + + DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", + dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); + + [myView setDestroyNotifySent: false]; + setJavaWindowObject(env, jthis, myView, YES); + + DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", + dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); + NS_DURING - // Available >= 10.5 - Makes the menubar disapear if( fullscreen ) { /** * See Bug 914: We don't use exclusive fullscreen anymore (capturing display) @@ -834,29 +847,18 @@ NS_DURING * <https://developer.apple.com/library/mac/documentation/graphicsimaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayCapture.html> * if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { + // Available >= 10.5 - Makes the menubar disapear [myView enterFullScreenMode: myScreen withOptions:NULL]; } */ - if ( 0 != myView->fullscreenPresentationOptions ) { - [NSApp setPresentationOptions: myView->fullscreenPresentationOptions]; - } - } else { - if ( 0 != myView->defaultPresentationOptions ) { - [NSApp setPresentationOptions: myView->defaultPresentationOptions]; + if( myWindow->hasPresentationSwitch ) { + DBG_PRINT( "initWindow0.%d - %p view %p, setPresentationOptions 0x%X\n", + dbgIdx++, myWindow, myView, (int)myWindow->fullscreenPresentationOptions); + [NSApp setPresentationOptions: myWindow->fullscreenPresentationOptions]; } } NS_HANDLER NS_ENDHANDLER - // Set the next responder to be the window so that we can forward - // right mouse button down events - [myView setNextResponder: myWindow]; - - DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", - dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); - - [myView setDestroyNotifySent: false]; - setJavaWindowObject(env, jthis, myView, YES); - DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); @@ -890,6 +892,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 return; } NewtView* mView = (NewtView *)[mWin contentView]; + BOOL fullscreen = mWin->isFullscreenWindow; BOOL destroyNotifySent, isNSView, isNewtView; if( NULL != mView ) { isNSView = [mView isKindOfClass:[NSView class]]; @@ -901,8 +904,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 destroyNotifySent = false; } - DBG_PRINT( "windowClose.0 - %p, destroyNotifySent %d, view %p [isNSView %d, isNewtView %d], parent %p\n", - mWin, destroyNotifySent, mView, isNSView, isNewtView, pWin); + DBG_PRINT( "windowClose.0 - %p, destroyNotifySent %d, view %p [isNSView %d, isNewtView %d], fullscreen %d, parent %p\n", + mWin, destroyNotifySent, mView, isNSView, isNewtView, (int)fullscreen, pWin); [mWin setRealized: NO]; @@ -913,8 +916,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 } NS_DURING + /** + * See Bug 914: We don't use exclusive fullscreen anymore (capturing display) + * See initWindow0(..) above .. if(NULL!=mView) { - // Available >= 10.5 - Makes the menubar disapear BOOL iifs; if ( [mView respondsToSelector:@selector(isInFullScreenMode)] ) { iifs = [mView isInFullScreenMode]; @@ -924,7 +929,15 @@ NS_DURING if(iifs && [mView respondsToSelector:@selector(exitFullScreenModeWithOptions:)] ) { [mView exitFullScreenModeWithOptions: NULL]; } - // Note: mWin's release will also release it's mView! + } */ + // Note: mWin's release will also release it's mView! + DBG_PRINT( "windowClose.1a - %p view %p, fullscreen %d, hasPresSwitch %d, defaultPresentationOptions 0x%X\n", + mWin, mView, (int)fullscreen, (int)mWin->hasPresentationSwitch, (int)mWin->defaultPresentationOptions); + + if( fullscreen && mWin->hasPresentationSwitch ) { + DBG_PRINT( "windowClose.1b - %p view %p, setPresentationOptions 0x%X\n", + mWin, mView, (int)mWin->defaultPresentationOptions); + [NSApp setPresentationOptions: mWin->defaultPresentationOptions]; } NS_HANDLER NS_ENDHANDLER @@ -934,7 +947,7 @@ NS_ENDHANDLER } [mWin orderOut: mWin]; - DBG_PRINT( "windowClose.1 - %p view %p, parent %p\n", mWin, mView, pWin); + DBG_PRINT( "windowClose.2 - %p view %p, parent %p\n", mWin, mView, pWin); [mWin release]; @@ -1208,7 +1221,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTo NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); - DBG_PRINT( "setAlwaysOnTop0 - window: %p (START)\n", win); + DBG_PRINT( "setAlwaysOnTop0 - window: %p, atop %d (START)\n", win, (int)atop); if(atop) { [win setLevel:NSFloatingWindowLevel]; @@ -1216,7 +1229,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTo [win setLevel:NSNormalWindowLevel]; } - DBG_PRINT( "setAlwaysOnTop0 - window: %p (END)\n", win); + DBG_PRINT( "setAlwaysOnTop0 - window: %p, atop %d (END)\n", win, (int)atop); [pool release]; } diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index a3bd5c41b..ba60b5665 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -64,9 +64,6 @@ volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; NSCursor * myCursor; -@public - NSUInteger defaultPresentationOptions; - NSUInteger fullscreenPresentationOptions; } - (id)initWithFrame:(NSRect)frameRect; @@ -113,7 +110,6 @@ @interface NewtMacWindow : NSWindow #endif { - BOOL isFullscreenWindow; BOOL mouseConfined; BOOL mouseVisible; BOOL mouseInside; @@ -122,6 +118,10 @@ BOOL modsDown[4]; // shift, ctrl, alt/option, win/command NSPoint lastInsideMousePosition; @public + BOOL hasPresentationSwitch; + NSUInteger defaultPresentationOptions; + NSUInteger fullscreenPresentationOptions; + BOOL isFullscreenWindow; int cachedInsets[4]; // l, r, t, b } diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 266b63081..4b0198c7e 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -129,27 +129,6 @@ static jmethodID windowRepaintID = NULL; */ myCursor = NULL; - // OSX 10.6 - if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && - [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { - defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; - fullscreenPresentationOptions = - // NSApplicationPresentationDefault| - // NSApplicationPresentationAutoHideDock| - NSApplicationPresentationHideDock| - // NSApplicationPresentationAutoHideMenuBar| - NSApplicationPresentationHideMenuBar| - NSApplicationPresentationDisableAppleMenu| - // NSApplicationPresentationDisableProcessSwitching| - // NSApplicationPresentationDisableSessionTermination| - NSApplicationPresentationDisableHideApplication| - // NSApplicationPresentationDisableMenuBarTransparency| - 0 ; - } else { - defaultPresentationOptions = 0; - fullscreenPresentationOptions = 0; - } - DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; } @@ -466,6 +445,29 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { styleMask: windowStyle backing: bufferingType defer: deferCreation]; + // OSX 10.6 + if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && + [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { + hasPresentationSwitch = YES; + defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; + fullscreenPresentationOptions = + // NSApplicationPresentationDefault| + // NSApplicationPresentationAutoHideDock| + NSApplicationPresentationHideDock| + // NSApplicationPresentationAutoHideMenuBar| + NSApplicationPresentationHideMenuBar| + NSApplicationPresentationDisableAppleMenu| + // NSApplicationPresentationDisableProcessSwitching| + // NSApplicationPresentationDisableSessionTermination| + NSApplicationPresentationDisableHideApplication| + // NSApplicationPresentationDisableMenuBarTransparency| + // NSApplicationPresentationFullScreen| // OSX 10.7 + 0 ; + } else { + hasPresentationSwitch = NO; + defaultPresentationOptions = 0; + fullscreenPresentationOptions = 0; + } isFullscreenWindow = isfs; // Why is this necessary? Without it we don't get any of the // delegate methods like resizing and window movement. @@ -483,7 +485,8 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { mouseInside = NO; cursorIsHidden = NO; realized = YES; - DBG_PRINT("NewtWindow::create: %p, realized %d (refcnt %d)\n", res, realized, (int)[res retainCount]); + DBG_PRINT("NewtWindow::create: %p, realized %d, hasPresentationSwitch %d[defaultOptions 0x%X, fullscreenOptions 0x%X], (refcnt %d)\n", + res, realized, (int)hasPresentationSwitch, (int)defaultPresentationOptions, (int)fullscreenPresentationOptions, (int)[res retainCount]); return res; } |