From 67eadf1e97ad66bc93d79757c3c6e06df346ef88 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 28 Aug 2015 12:00:06 +0200 Subject: [PATCH] Fix glfwIconifyWindow not restoring video mode Fixes #590. --- README.md | 2 ++ src/cocoa_window.m | 14 +++++++------- src/win32_window.c | 12 ++++++------ src/x11_window.c | 16 ++++++++++------ 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3176fba5..e3827734 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,8 @@ GLFW bundles a number of dependencies in the `deps/` directory. - Removed all mention of GLU in examples, build files and package dependencies - Bugfix: Initialization failed on headless systems - Bugfix: The cached current context could get out of sync + - Bugfix: `glfwIconifyWindow` did not restore the original video mode for full + screen windows created with `GLFW_AUTO_ICONIFY` - [Win32] Renamed hybrid GPU override compile-time option to `_GLFW_USE_HYBRID_HPG` and added support for AMD PowerXpress systems - [Win32] Bugfix: `glfwGetVideoModes` included unusable modes on some systems diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5387839f..d7400fc1 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -234,19 +234,22 @@ static int translateKey(unsigned int key) - (void)windowDidMiniaturize:(NSNotification *)notification { + if (window->monitor) + leaveFullscreenMode(window); + _glfwInputWindowIconify(window, GL_TRUE); } - (void)windowDidDeminiaturize:(NSNotification *)notification { + if (window->monitor) + enterFullscreenMode(window); + _glfwInputWindowIconify(window, GL_FALSE); } - (void)windowDidBecomeKey:(NSNotification *)notification { - if (window->monitor && window->autoIconify) - enterFullscreenMode(window); - if (_glfw.cursorWindow == window && window->cursorMode == GLFW_CURSOR_DISABLED) { @@ -260,7 +263,7 @@ static int translateKey(unsigned int key) - (void)windowDidResignKey:(NSNotification *)notification { if (window->monitor && window->autoIconify) - leaveFullscreenMode(window); + _glfwPlatformIconifyWindow(window); _glfwInputWindowFocus(window, GL_FALSE); } @@ -885,9 +888,6 @@ static GLboolean createWindow(_GLFWwindow* window, if (wndconfig->monitor) { [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; - - if (window->autoIconify) - [window->ns.object setHidesOnDeactivate:YES]; } else { diff --git a/src/win32_window.c b/src/win32_window.c index 944564ce..9d47c25a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -280,9 +280,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->cursorMode != GLFW_CURSOR_NORMAL) _glfwPlatformApplyCursorMode(window); - if (window->monitor && window->autoIconify) - enterFullscreenMode(window); - _glfwInputWindowFocus(window, GL_TRUE); return 0; } @@ -293,10 +290,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, restoreCursor(window); if (window->monitor && window->autoIconify) - { _glfwPlatformIconifyWindow(window); - leaveFullscreenMode(window); - } _glfwInputWindowFocus(window, GL_FALSE); return 0; @@ -523,12 +517,18 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (!window->win32.iconified && wParam == SIZE_MINIMIZED) { window->win32.iconified = GL_TRUE; + if (window->monitor) + leaveFullscreenMode(window); + _glfwInputWindowIconify(window, GL_TRUE); } else if (window->win32.iconified && (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)) { window->win32.iconified = GL_FALSE; + if (window->monitor) + enterFullscreenMode(window); + _glfwInputWindowIconify(window, GL_FALSE); } diff --git a/src/x11_window.c b/src/x11_window.c index 251e09ad..f64a3220 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1256,9 +1256,6 @@ static void processEvent(XEvent *event) if (window->cursorMode == GLFW_CURSOR_DISABLED) disableCursor(window); - if (window->monitor && window->autoIconify) - enterFullscreenMode(window); - _glfwInputWindowFocus(window, GL_TRUE); return; } @@ -1280,10 +1277,7 @@ static void processEvent(XEvent *event) restoreCursor(window); if (window->monitor && window->autoIconify) - { _glfwPlatformIconifyWindow(window); - leaveFullscreenMode(window); - } _glfwInputWindowFocus(window, GL_FALSE); return; @@ -1302,9 +1296,19 @@ static void processEvent(XEvent *event) { const int state = getWindowState(window); if (state == IconicState) + { + if (window->monitor) + leaveFullscreenMode(window); + _glfwInputWindowIconify(window, GL_TRUE); + } else if (state == NormalState) + { + if (window->monitor) + enterFullscreenMode(window); + _glfwInputWindowIconify(window, GL_FALSE); + } } return;