Commit 0e846883 authored by Camilla Berglund's avatar Camilla Berglund
Browse files

Clarify cursor position variable names

parent 72b3a7a5
......@@ -78,7 +78,7 @@ typedef struct _GLFWwindowNS
// The total sum of the distances the cursor has been warped
// since the last cursor motion event was processed
// This is kept to counteract Cocoa doing the same internally
double warpDeltaX, warpDeltaY;
double cursorWarpDeltaX, cursorWarpDeltaY;
} _GLFWwindowNS;
......
......@@ -423,8 +423,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
if (window->cursorMode == GLFW_CURSOR_DISABLED)
{
_glfwInputCursorMotion(window,
[event deltaX] - window->ns.warpDeltaX,
[event deltaY] - window->ns.warpDeltaY);
[event deltaX] - window->ns.cursorWarpDeltaX,
[event deltaY] - window->ns.cursorWarpDeltaY);
}
else
{
......@@ -434,8 +434,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
_glfwInputCursorMotion(window, pos.x, contentRect.size.height - pos.y);
}
window->ns.warpDeltaX = 0;
window->ns.warpDeltaY = 0;
window->ns.cursorWarpDeltaX = 0;
window->ns.cursorWarpDeltaY = 0;
}
- (void)rightMouseDown:(NSEvent *)event
......@@ -1402,8 +1402,8 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
const NSRect contentRect = [window->ns.view frame];
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
window->ns.warpDeltaX += x - pos.x;
window->ns.warpDeltaY += y - contentRect.size.height + pos.y;
window->ns.cursorWarpDeltaX += x - pos.x;
window->ns.cursorWarpDeltaY += y - contentRect.size.height + pos.y;
if (window->monitor)
{
......
......@@ -59,19 +59,19 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
if (oldMode == GLFW_CURSOR_DISABLED)
{
_glfwPlatformSetCursorPos(window,
_glfw.cursorPosX,
_glfw.cursorPosY);
_glfw.restoreCursorPosX,
_glfw.restoreCursorPosY);
}
else if (newMode == GLFW_CURSOR_DISABLED)
{
int width, height;
_glfwPlatformGetCursorPos(window,
&_glfw.cursorPosX,
&_glfw.cursorPosY);
&_glfw.restoreCursorPosX,
&_glfw.restoreCursorPosY);
window->cursorPosX = _glfw.cursorPosX;
window->cursorPosY = _glfw.cursorPosY;
window->virtualCursorPosX = _glfw.restoreCursorPosX;
window->virtualCursorPosY = _glfw.restoreCursorPosY;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
......@@ -198,11 +198,11 @@ void _glfwInputCursorMotion(_GLFWwindow* window, double x, double y)
if (x == 0.0 && y == 0.0)
return;
window->cursorPosX += x;
window->cursorPosY += y;
window->virtualCursorPosX += x;
window->virtualCursorPosY += y;
x = window->cursorPosX;
y = window->cursorPosY;
x = window->virtualCursorPosX;
y = window->virtualCursorPosY;
}
if (window->callbacks.cursorPos)
......@@ -356,9 +356,9 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
if (window->cursorMode == GLFW_CURSOR_DISABLED)
{
if (xpos)
*xpos = window->cursorPosX;
*xpos = window->virtualCursorPosX;
if (ypos)
*ypos = window->cursorPosY;
*ypos = window->virtualCursorPosY;
}
else
_glfwPlatformGetCursorPos(window, xpos, ypos);
......@@ -386,8 +386,8 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
if (window->cursorMode == GLFW_CURSOR_DISABLED)
{
// Only update the accumulated position if the cursor is disabled
window->cursorPosX = xpos;
window->cursorPosY = ypos;
window->virtualCursorPosX = xpos;
window->virtualCursorPosY = ypos;
}
else
{
......
......@@ -359,13 +359,13 @@ struct _GLFWwindow
int maxwidth, maxheight;
int numer, denom;
// Window input state
GLFWbool stickyKeys;
GLFWbool stickyMouseButtons;
double cursorPosX, cursorPosY;
int cursorMode;
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
char keys[GLFW_KEY_LAST + 1];
// Virtual cursor position when cursor is disabled
double virtualCursorPosX, virtualCursorPosY;
_GLFWcontext context;
......@@ -437,7 +437,8 @@ struct _GLFWlibrary
int refreshRate;
} hints;
double cursorPosX, cursorPosY;
// Where to place the cursor when re-enabled
double restoreCursorPosX, restoreCursorPosY;
_GLFWcursor* cursorListHead;
......
......@@ -201,8 +201,8 @@ static void handlePointerButton(_GLFWwindow* window,
static void handlePointerMotion(_GLFWwindow* window,
const MirPointerEvent* pointer_event)
{
int current_x = window->cursorPosX;
int current_y = window->cursorPosY;
int current_x = window->virtualCursorPosX;
int current_y = window->virtualCursorPosY;
int x = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_x);
int y = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_y);
int dx = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_hscroll);
......
......@@ -237,7 +237,7 @@ typedef struct _GLFWwindowWin32
GLFWbool iconified;
// The last received cursor position, regardless of source
int cursorPosX, cursorPosY;
int lastCursorPosX, lastCursorPosY;
} _GLFWwindowWin32;
......
......@@ -572,14 +572,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
break;
_glfwInputCursorMotion(window,
x - window->win32.cursorPosX,
y - window->win32.cursorPosY);
x - window->win32.lastCursorPosX,
y - window->win32.lastCursorPosY);
}
else
_glfwInputCursorMotion(window, x, y);
window->win32.cursorPosX = x;
window->win32.cursorPosY = y;
window->win32.lastCursorPosX = x;
window->win32.lastCursorPosY = y;
if (!window->win32.cursorTracked)
{
......@@ -1386,8 +1386,8 @@ void _glfwPlatformPollEvents(void)
// 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)
if (window->win32.lastCursorPosX != width / 2 ||
window->win32.lastCursorPosY != height / 2)
{
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
}
......@@ -1435,8 +1435,8 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
POINT pos = { (int) xpos, (int) ypos };
// Store the new position so it can be recognized later
window->win32.cursorPosX = pos.x;
window->win32.cursorPosY = pos.y;
window->win32.lastCursorPosX = pos.x;
window->win32.lastCursorPosY = pos.y;
ClientToScreen(window->win32.handle, &pos);
SetCursorPos(pos.x, pos.y);
......
......@@ -224,10 +224,12 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
window->cursorPosX = width / 2;
window->cursorPosY = height / 2;
window->virtualCursorPosX = width / 2;
window->virtualCursorPosY = height / 2;
_glfwPlatformSetCursorPos(window, window->cursorPosX, window->cursorPosY);
_glfwPlatformSetCursorPos(window,
window->virtualCursorPosX,
window->virtualCursorPosY);
}
else
{
......
......@@ -118,9 +118,9 @@ typedef struct _GLFWwindowX11
int xpos, ypos;
// The last received cursor position, regardless of source
double cursorPosX, cursorPosY;
double lastCursorPosX, lastCursorPosY;
// The last position the cursor was warped to by GLFW
int warpPosX, warpPosY;
int warpCursorPosX, warpCursorPosY;
// The information from the last KeyPress event
struct {
......
......@@ -1149,7 +1149,7 @@ static void processEvent(XEvent *event)
const int x = event->xmotion.x;
const int y = event->xmotion.y;
if (x != window->x11.warpPosX || y != window->x11.warpPosY)
if (x != window->x11.warpCursorPosX || y != window->x11.warpCursorPosY)
{
// The cursor was moved by something other than GLFW
......@@ -1159,15 +1159,15 @@ static void processEvent(XEvent *event)
return;
_glfwInputCursorMotion(window,
x - window->x11.cursorPosX,
y - window->x11.cursorPosY);
x - window->x11.lastCursorPosX,
y - window->x11.lastCursorPosY);
}
else
_glfwInputCursorMotion(window, x, y);
}
window->x11.cursorPosX = x;
window->x11.cursorPosY = y;
window->x11.lastCursorPosX = x;
window->x11.lastCursorPosY = y;
return;
}
......@@ -2071,8 +2071,8 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
{
// Store the new position so it can be recognized later
window->x11.warpPosX = (int) x;
window->x11.warpPosY = (int) y;
window->x11.warpCursorPosX = (int) x;
window->x11.warpCursorPosY = (int) y;
XWarpPointer(_glfw.x11.display, None, window->x11.handle,
0,0,0,0, (int) x, (int) y);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment