mirror of
https://github.com/glfw/glfw.git
synced 2026-09-20 08:23:13 +00:00
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.
This commit is contained in:
+8
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user