From e2bb5e172645715b6cc0cfe1017aa10d14fec41d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 16 Aug 2015 13:55:44 +0200 Subject: [PATCH] Fix glfwWaitEvents generating events on Win32 Disabled cursor mode caused subsequent glfwWaitEvents calls to return directly on Win32 due to cursor re-centring emitting WM_MOUSEMOVE. Fixes #543. --- README.md | 2 ++ src/win32_window.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3595eadc..55aea2a5 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ GLFW bundles a number of dependencies in the `deps/` directory. - [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 + - [Win32] Bugfix: `glfwWaitEvents` would return directly for focused windows in + disabled cursor mode - [Cocoa] Bugfix: The cached `NSScreen` for a monitor could get out of sync - [Cocoa] Bugfix: The `GLFW_AUTO_ICONIFY` window hint was ignored - [Cocoa] Bugfix: Resizing a window to its minimum size would segfault diff --git a/src/win32_window.c b/src/win32_window.c index 88cd483f..f38c0700 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1037,12 +1037,18 @@ void _glfwPlatformPollEvents(void) _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, 0, GLFW_RELEASE, mods); } - // Did the cursor move in an focused window that has disabled the cursor if (window->cursorMode == GLFW_CURSOR_DISABLED) { int width, height; _glfwPlatformGetWindowSize(window, &width, &height); - _glfwPlatformSetCursorPos(window, width / 2, height / 2); + + // NOTE: Re-center the cursor only if it has moved since the last + // call, to avoid breaking glfwWaitEvents with WM_MOUSEMOVE + if (window->win32.cursorPosX != width / 2 || + window->win32.cursorPosY != height / 2) + { + _glfwPlatformSetCursorPos(window, width / 2, height / 2); + } } } }