Bläddra i källkod

Fix incorrect cursor position

When reactivating the cursor its position was updated visually but not
internally which caused glfwGetCursorPos to return wrong values.
Niklas Behrens 12 år sedan
förälder
incheckning
a55c3f48eb
1 ändrade filer med 5 tillägg och 0 borttagningar
  1. 5 0
      src/input.c

+ 5 - 0
src/input.c

@@ -55,7 +55,12 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
     if (window == _glfw.focusedWindow)
     if (window == _glfw.focusedWindow)
     {
     {
         if (oldMode == GLFW_CURSOR_DISABLED)
         if (oldMode == GLFW_CURSOR_DISABLED)
+        {
+            window->cursorPosX = _glfw.cursorPosX;
+            window->cursorPosY = _glfw.cursorPosY;
+
             _glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
             _glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
+        }
         else if (newMode == GLFW_CURSOR_DISABLED)
         else if (newMode == GLFW_CURSOR_DISABLED)
         {
         {
             int width, height;
             int width, height;