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

Initial OS X fullscreen iconification work.

glfwIconifyWindow now pulls the view out of fullscreen mode and restores
the original display mode, reversing the process when deminiaturized.
This commit is contained in:
Camilla Berglund 2013-05-02 18:16:23 +02:00
parent 58ae11778a
commit efe3ee8818

View File

@ -33,6 +33,34 @@
#include <crt_externs.h> #include <crt_externs.h>
// Enter fullscreen mode
//
static void enterFullscreenMode(_GLFWwindow* window)
{
if ([window->ns.view isInFullScreenMode])
return;
_glfwSetVideoMode(window->monitor, &window->videoMode);
[window->ns.view enterFullScreenMode:window->monitor->ns.screen
withOptions:nil];
}
// Leave fullscreen mode
//
static void leaveFullscreenMode(_GLFWwindow* window)
{
if (![window->ns.view isInFullScreenMode])
return;
_glfwRestoreVideoMode(window->monitor);
// Exit full screen after the video restore to avoid a nasty display
// flickering during the fade
[window->ns.view exitFullScreenModeWithOptions:nil];
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Delegate for window related notifications // Delegate for window related notifications
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -102,6 +130,9 @@ static void centerCursor(_GLFWwindow *window)
- (void)windowDidDeminiaturize:(NSNotification *)notification - (void)windowDidDeminiaturize:(NSNotification *)notification
{ {
if (window->monitor)
enterFullscreenMode(window);
_glfwInputWindowIconify(window, GL_FALSE); _glfwInputWindowIconify(window, GL_FALSE);
} }
@ -781,14 +812,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
[window->nsgl.context setView:window->ns.view]; [window->nsgl.context setView:window->ns.view];
if (wndconfig->monitor) if (wndconfig->monitor)
{ enterFullscreenMode(window);
if (!_glfwSetVideoMode(window->monitor, &window->videoMode))
return GL_FALSE;
_glfwPlatformShowWindow(window);
[window->ns.view enterFullScreenMode:wndconfig->monitor->ns.screen
withOptions:nil];
}
NSPoint point = [[NSCursor currentCursor] hotSpot]; NSPoint point = [[NSCursor currentCursor] hotSpot];
window->cursorPosX = point.x; window->cursorPosX = point.x;
@ -802,13 +826,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
[window->ns.object orderOut:nil]; [window->ns.object orderOut:nil];
if (window->monitor) if (window->monitor)
{ leaveFullscreenMode(window);
_glfwRestoreVideoMode(window->monitor);
// Exit full screen after the video restore to avoid a nasty display
// flickering during the fade.
[window->ns.view exitFullScreenModeWithOptions:nil];
}
_glfwDestroyContext(window); _glfwDestroyContext(window);
@ -864,6 +882,9 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwPlatformIconifyWindow(_GLFWwindow* window) void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{ {
if (window->monitor)
leaveFullscreenMode(window);
[window->ns.object miniaturize:nil]; [window->ns.object miniaturize:nil];
} }