1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-30 05:58:52 -05:00

Moved OS X from full screen view to window.

This commit is contained in:
Camilla Berglund 2014-10-28 22:10:39 +01:00
parent da7fec86c4
commit 6743761c2c

View File

@ -71,42 +71,14 @@ static void updateModeCursor(_GLFWwindow* window)
// //
static void enterFullscreenMode(_GLFWwindow* window) static void enterFullscreenMode(_GLFWwindow* window)
{ {
if ([window->ns.view isInFullScreenMode])
return;
_glfwSetVideoMode(window->monitor, &window->videoMode); _glfwSetVideoMode(window->monitor, &window->videoMode);
NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO],
NSFullScreenModeAllScreens,
nil];
[window->ns.view enterFullScreenMode:window->monitor->ns.screen
withOptions:options];
// HACK: Synthesize focus event as window does not become key when the view
// is made full screen
// TODO: Remove this when moving to a full screen window
_glfwInputWindowFocus(window, GL_TRUE);
} }
// Leave fullscreen mode // Leave fullscreen mode
// //
static void leaveFullscreenMode(_GLFWwindow* window) static void leaveFullscreenMode(_GLFWwindow* window)
{ {
if (![window->ns.view isInFullScreenMode])
return;
// HACK: Synthesize focus event as window does not become key when the view
// is made full screen
// TODO: Remove this when moving to a full screen window
_glfwInputWindowFocus(window, GL_FALSE);
_glfwRestoreVideoMode(window->monitor); _glfwRestoreVideoMode(window->monitor);
// Exit full screen after the video restore to avoid a nasty display
// flickering during the fade
[window->ns.view exitFullScreenModeWithOptions:nil];
} }
// Transforms the specified y-coordinate between the CG display and NS screen // Transforms the specified y-coordinate between the CG display and NS screen
@ -956,8 +928,15 @@ static GLboolean createWindow(_GLFWwindow* window,
styleMask |= NSResizableWindowMask; styleMask |= NSResizableWindowMask;
} }
NSRect contentRect;
if (wndconfig->monitor)
contentRect = [wndconfig->monitor->ns.screen frame];
else
contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
window->ns.object = [[GLFWWindow alloc] window->ns.object = [[GLFWWindow alloc]
initWithContentRect:NSMakeRect(0, 0, wndconfig->width, wndconfig->height) initWithContentRect:contentRect
styleMask:styleMask styleMask:styleMask
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:NO]; defer:NO];
@ -976,20 +955,23 @@ static GLboolean createWindow(_GLFWwindow* window,
#if defined(_GLFW_USE_RETINA) #if defined(_GLFW_USE_RETINA)
[window->ns.view setWantsBestResolutionOpenGLSurface:YES]; [window->ns.view setWantsBestResolutionOpenGLSurface:YES];
#endif #endif
if (wndconfig->resizable)
[window->ns.object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
} }
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ #endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
if (wndconfig->monitor)
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
else
{
[window->ns.object center];
if (wndconfig->floating) if (wndconfig->floating)
[window->ns.object setLevel:NSFloatingWindowLevel]; [window->ns.object setLevel:NSFloatingWindowLevel];
}
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]]; [window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
[window->ns.object setContentView:window->ns.view]; [window->ns.object setContentView:window->ns.view];
[window->ns.object setDelegate:window->ns.delegate]; [window->ns.object setDelegate:window->ns.delegate];
[window->ns.object setAcceptsMouseMovedEvents:YES]; [window->ns.object setAcceptsMouseMovedEvents:YES];
[window->ns.object center];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
@ -1036,7 +1018,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
[window->nsgl.context setView:window->ns.view]; [window->nsgl.context setView:window->ns.view];
if (wndconfig->monitor) if (wndconfig->monitor)
{
_glfwPlatformShowWindow(window);
enterFullscreenMode(window); enterFullscreenMode(window);
}
return GL_TRUE; return GL_TRUE;
} }
@ -1152,7 +1137,6 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
[window->ns.object makeKeyAndOrderFront:nil]; [window->ns.object makeKeyAndOrderFront:nil];
_glfwInputWindowVisibility(window, GL_TRUE);
} }
void _glfwPlatformUnhideWindow(_GLFWwindow* window) void _glfwPlatformUnhideWindow(_GLFWwindow* window)