From 2660b27cf39ccb88d3161179ff58ca86df45b753 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 13 Oct 2011 15:20:59 +0200 Subject: [PATCH] Renamed internal cursor position in preparation of new API. --- src/cocoa_window.m | 4 ++-- src/input.c | 30 ++++++++++++++++-------------- src/internal.h | 2 +- src/win32_window.c | 8 ++++---- src/x11_window.c | 4 ++-- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 136a4378..4f662faf 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -688,8 +688,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, glfwMakeContextCurrent(window); NSPoint point = [[NSCursor currentCursor] hotSpot]; - window->mousePosX = point.x; - window->mousePosY = point.y; + window->cursorPosX = point.x; + window->cursorPosY = point.y; window->windowNoResize = wndconfig->windowNoResize; diff --git a/src/input.c b/src/input.c index 42e3af97..56ab0e5d 100644 --- a/src/input.c +++ b/src/input.c @@ -125,20 +125,22 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y) if (!x && !y) return; - window->mousePosX += x; - window->mousePosY += y; + window->cursorPosX += x; + window->cursorPosY += y; } else { - if (window->mousePosX == x && window->mousePosY == y) + if (window->cursorPosX == x && window->cursorPosY == y) return; - window->mousePosX = x; - window->mousePosY = y; + window->cursorPosX = x; + window->cursorPosY = y; } if (_glfwLibrary.mousePosCallback) - _glfwLibrary.mousePosCallback(window, window->mousePosX, window->mousePosY); + _glfwLibrary.mousePosCallback(window, + window->cursorPosX, + window->cursorPosY); } @@ -229,10 +231,10 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos) // Return mouse position if (xpos != NULL) - *xpos = window->mousePosX; + *xpos = window->cursorPosX; if (ypos != NULL) - *ypos = window->mousePosY; + *ypos = window->cursorPosY; } @@ -258,12 +260,12 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos) } // Don't do anything if the mouse position did not change - if (xpos == window->mousePosX && ypos == window->mousePosY) + if (xpos == window->cursorPosX && ypos == window->cursorPosY) return; // Set GLFW mouse position - window->mousePosX = xpos; - window->mousePosY = ypos; + window->cursorPosX = xpos; + window->cursorPosY = ypos; // Do not move physical cursor in locked cursor mode if (window->cursorMode == GLFW_CURSOR_CAPTURED) @@ -331,8 +333,8 @@ GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode) { _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY); _glfwInputCursorMotion(window, - centerPosX - window->mousePosX, - centerPosY - window->mousePosY); + centerPosX - window->cursorPosX, + centerPosY - window->cursorPosY); } _glfwPlatformSetCursorMode(window, mode); @@ -411,7 +413,7 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun) _GLFWwindow* window; for (window = _glfwLibrary.windowListHead; window; window = window->next) - cbfun(window, window->mousePosX, window->mousePosY); + cbfun(window, window->cursorPosX, window->cursorPosY); } } diff --git a/src/internal.h b/src/internal.h index 89c77cd7..3c27bba1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -184,7 +184,7 @@ struct _GLFWwindow GLboolean stickyMouseButtons; GLboolean keyRepeat; GLboolean sysKeysDisabled; // system keys disabled flag - int mousePosX, mousePosY; + int cursorPosX, cursorPosY; int cursorMode; int scrollX, scrollY; char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1]; diff --git a/src/win32_window.c b/src/win32_window.c index 3442f5a3..d81da139 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1371,8 +1371,8 @@ static int createWindow(_GLFWwindow* window, // Initialize mouse position data GetCursorPos(&pos); ScreenToClient(window->Win32.handle, &pos); - window->Win32.oldMouseX = window->mousePosX = pos.x; - window->Win32.oldMouseY = window->mousePosY = pos.y; + window->Win32.oldMouseX = window->cursorPosX = pos.x; + window->Win32.oldMouseY = window->cursorPosY = pos.y; return GL_TRUE; } @@ -1786,8 +1786,8 @@ void _glfwPlatformPollEvents(void) } else { - //window->Win32.oldMouseX = window->mousePosX; - //window->Win32.oldMouseY = window->mousePosY; + //window->Win32.oldMouseX = window->cursorPosX; + //window->Win32.oldMouseY = window->cursorPosY; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) diff --git a/src/x11_window.c b/src/x11_window.c index 1afa814a..3ce5e832 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1457,8 +1457,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, // TODO: Probably check for some corner cases here. - window->mousePosX = windowX; - window->mousePosY = windowY; + window->cursorPosX = windowX; + window->cursorPosY = windowY; } return GL_TRUE;