From f175b2dddc7d7903361fa73e7bc4d1a229106e20 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 19 Apr 2013 00:19:48 +0200 Subject: [PATCH] Only apply cursor mode to focused windows. --- src/input.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/input.c b/src/input.c index 5485db4b..c350efb9 100644 --- a/src/input.c +++ b/src/input.c @@ -52,20 +52,24 @@ static void setCursorMode(_GLFWwindow* window, int newMode) if (oldMode == newMode) return; - if (oldMode == GLFW_CURSOR_CAPTURED) - _glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY); - else if (newMode == GLFW_CURSOR_CAPTURED) + if (window == _glfw.focusedWindow) { - 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.cursorPosY = window->cursorPosY; + _glfw.cursorPosX = window->cursorPosX; + _glfw.cursorPosY = window->cursorPosY; - _glfwPlatformGetWindowSize(window, &width, &height); - _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0); + _glfwPlatformGetWindowSize(window, &width, &height); + _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0); + } + + _glfwPlatformSetCursorMode(window, newMode); } - _glfwPlatformSetCursorMode(window, newMode); window->cursorMode = newMode; }