diff --git a/README.md b/README.md index a93c60ae..f7d5d67f 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: The Cygwin DLL was installed to the wrong directory (#1035) - [Win32] Bugfix: Normalization of axis data via XInput was incorrect (#1045) - [Win32] Bugfix: `glfw3native.h` would undefine a foreign `APIENTRY` (#1062) +- [Win32] Bugfix: Disabled cursor mode prevented use of caption buttons + (#650,#1071) - [X11] Moved to XI2 `XI_RawMotion` for disable cursor mode motion input (#125) - [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading - [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X diff --git a/src/win32_platform.h b/src/win32_platform.h index 0cc524d6..233510ef 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -233,6 +233,7 @@ typedef struct _GLFWwindowWin32 HICON smallIcon; GLFWbool cursorTracked; + GLFWbool frameAction; GLFWbool iconified; GLFWbool maximized; diff --git a/src/win32_window.c b/src/win32_window.c index 092ce5e0..2b4ddede 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -495,10 +495,47 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, switch (uMsg) { + case WM_MOUSEACTIVATE: + { + // HACK: Postpone cursor disabling when the window was activated by + // clicking a caption button + if (HIWORD(lParam) == WM_LBUTTONDOWN) + { + if (LOWORD(lParam) == HTCLOSE || + LOWORD(lParam) == HTMINBUTTON || + LOWORD(lParam) == HTMAXBUTTON) + { + window->win32.frameAction = GLFW_TRUE; + } + } + + break; + } + + case WM_CAPTURECHANGED: + { + // HACK: Disable the cursor once the caption button action has been + // completed or cancelled + if (lParam == 0 && window->win32.frameAction) + { + if (window->cursorMode == GLFW_CURSOR_DISABLED) + _glfwPlatformSetCursorMode(window, GLFW_CURSOR_DISABLED); + + window->win32.frameAction = GLFW_FALSE; + } + + break; + } + case WM_SETFOCUS: { _glfwInputWindowFocus(window, GLFW_TRUE); + // HACK: Do not disable cursor while the user is interacting with + // a caption button + if (window->win32.frameAction) + break; + if (window->cursorMode == GLFW_CURSOR_DISABLED) _glfwPlatformSetCursorMode(window, GLFW_CURSOR_DISABLED); @@ -758,6 +795,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_ENTERSIZEMOVE: case WM_ENTERMENULOOP: { + // HACK: Postpone cursor disabling while the user is moving or + // resizing the window or using the menu if (window->cursorMode == GLFW_CURSOR_DISABLED) _glfwPlatformSetCursorMode(window, GLFW_CURSOR_NORMAL); @@ -767,6 +806,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_EXITSIZEMOVE: case WM_EXITMENULOOP: { + // HACK: Disable the cursor once the user is done moving or + // resizing the window or using the menu if (window->cursorMode == GLFW_CURSOR_DISABLED) _glfwPlatformSetCursorMode(window, GLFW_CURSOR_DISABLED);