From e640d840b710c79074cc99766222f86bda94f417 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 4 May 2016 16:04:26 +0200 Subject: [PATCH] Fix Win32 window size event race condition The old window size was reported after re-entering full screen and setting and reporting the new window size. Fixes #740. --- README.md | 2 ++ src/win32_window.c | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f0f827dd..0321e2cc 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ does not find Doxygen, the documentation will not be generated. trigger monitor callback - [Win32] Bugfix: No monitors were listed on headless and VMware guest systems - [Win32] Bugfix: Pressing Ctrl+Pause would report `GLFW_KEY_UNKNOWN` + - [Win32] Bugfix: Window size events would be reported in wrong order when + restoring a full screen window - [Cocoa] Made joystick polling more efficient - [Cocoa] Removed support for OS X 10.6 - [Cocoa] Bugfix: Full screen windows on secondary monitors were mispositioned diff --git a/src/win32_window.c b/src/win32_window.c index ed6bbe7f..944bff66 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -613,32 +613,39 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_SIZE: { + const GLFWbool iconified = + !window->win32.iconified && wParam == SIZE_MINIMIZED; + const GLFWbool restored = + window->win32.iconified && + (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED); + if (_glfw.cursorWindow == window) { if (window->cursorMode == GLFW_CURSOR_DISABLED) updateClipRect(window); } - if (!window->win32.iconified && wParam == SIZE_MINIMIZED) + if (iconified) + _glfwInputWindowIconify(window, GLFW_TRUE); + else if (restored) + _glfwInputWindowIconify(window, GLFW_FALSE); + + _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam)); + _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam)); + + if (iconified) { window->win32.iconified = GLFW_TRUE; if (window->monitor) releaseMonitor(window); - - _glfwInputWindowIconify(window, GLFW_TRUE); } - else if (window->win32.iconified && - (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)) + else if (restored) { window->win32.iconified = GLFW_FALSE; if (window->monitor) acquireMonitor(window); - - _glfwInputWindowIconify(window, GLFW_FALSE); } - _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam)); - _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam)); return 0; }