mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 20:11:58 +00:00
Only apply cursor mode to focused windows.
This commit is contained in:
parent
037c5ec6f5
commit
f175b2dddc
22
src/input.c
22
src/input.c
@ -52,20 +52,24 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
|
|||||||
if (oldMode == newMode)
|
if (oldMode == newMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (oldMode == GLFW_CURSOR_CAPTURED)
|
if (window == _glfw.focusedWindow)
|
||||||
_glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
|
|
||||||
else if (newMode == GLFW_CURSOR_CAPTURED)
|
|
||||||
{
|
{
|
||||||
int width, height;
|
if (oldMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
_glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
|
||||||
|
else if (newMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
|
||||||
_glfw.cursorPosX = window->cursorPosX;
|
_glfw.cursorPosX = window->cursorPosX;
|
||||||
_glfw.cursorPosY = window->cursorPosY;
|
_glfw.cursorPosY = window->cursorPosY;
|
||||||
|
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwPlatformSetCursorMode(window, newMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformSetCursorMode(window, newMode);
|
|
||||||
window->cursorMode = newMode;
|
window->cursorMode = newMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user