Fix #35225: new OS X Lion fullscreen did not work together well with old

fullscreen option. It was possible to enable both at the same time which got
you stuck in a state where it was impossible to exit fullscreen. Now I've made
them mutually exlusive, only one can be enabled at the same time.

Note the reason we need to support both is because the new Lion fullscreen does
not work with multiple monitors, it will just give black screens on the other
monitors. This is a limitation of OS X, you can find many complaints about this
online.
This commit is contained in:
Brecht Van Lommel 2013-05-06 13:39:25 +00:00
parent ad7a74f58d
commit 2a4ee23a25

@ -851,6 +851,16 @@ GHOST_TWindowState GHOST_WindowCocoa::getState() const
GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getState(): window invalid");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GHOST_TWindowState state;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
NSUInteger masks = [m_window styleMask];
if (masks & NSFullScreenWindowMask) {
// Lion style fullscreen
state = GHOST_kWindowStateFullScreen;
}
else
#endif
if (m_fullScreen) {
state = GHOST_kWindowStateFullScreen;
}
@ -959,8 +969,14 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
[m_window zoom:nil];
break;
case GHOST_kWindowStateFullScreen:
case GHOST_kWindowStateFullScreen: {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
NSUInteger masks = [m_window styleMask];
if (!m_fullScreen && !(masks & NSFullScreenWindowMask)) {
#else
if (!m_fullScreen) {
#endif
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/* This status change needs to be done before Cocoa call to enter fullscreen mode
@ -968,6 +984,11 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
* doesn't know view/window difference. */
m_fullScreen = true;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
/* Disable toggle for Lion style fullscreen */
[m_window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
//10.6 provides Cocoa functions to autoshow menu bar, and to change a window style
//Hide menu & dock if on primary screen. else only menu
@ -1017,12 +1038,27 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
[pool drain];
}
break;
}
case GHOST_kWindowStateNormal:
default:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
NSUInteger masks = [m_window styleMask];
if (masks & NSFullScreenWindowMask) {
// Lion style fullscreen
[m_window toggleFullScreen:nil];
}
else
#endif
if (m_fullScreen) {
m_fullScreen = false;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
/* Enable toggle for into Lion style fullscreen */
[m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
#endif
//Exit fullscreen
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
//Show again menu & dock if needed