mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Fixed jitter in captured cursor mode.
This commit is contained in:
parent
d6030808eb
commit
aa3364a73e
|
@ -86,7 +86,11 @@ typedef struct _GLFWwindowX11
|
||||||
GLboolean cursorGrabbed; // True if cursor is currently grabbed
|
GLboolean cursorGrabbed; // True if cursor is currently grabbed
|
||||||
GLboolean cursorHidden; // True if cursor is currently hidden
|
GLboolean cursorHidden; // True if cursor is currently hidden
|
||||||
GLboolean cursorCentered; // True if cursor was moved since last poll
|
GLboolean cursorCentered; // True if cursor was moved since last poll
|
||||||
|
|
||||||
|
// The last received cursor position, regardless of source
|
||||||
double cursorPosX, cursorPosY;
|
double cursorPosX, cursorPosY;
|
||||||
|
// The last position the cursor was warped to by GLFW
|
||||||
|
int warpPosX, warpPosY;
|
||||||
|
|
||||||
} _GLFWwindowX11;
|
} _GLFWwindowX11;
|
||||||
|
|
||||||
|
|
|
@ -580,8 +580,8 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
{
|
{
|
||||||
if (event->xmotion.x != window->x11.cursorPosX ||
|
if (event->xmotion.x != window->x11.warpPosX ||
|
||||||
event->xmotion.y != window->x11.cursorPosY)
|
event->xmotion.y != window->x11.warpPosY)
|
||||||
{
|
{
|
||||||
// The cursor was moved by something other than GLFW
|
// The cursor was moved by something other than GLFW
|
||||||
|
|
||||||
|
@ -601,13 +601,12 @@ static void processEvent(XEvent *event)
|
||||||
y = event->xmotion.y;
|
y = event->xmotion.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->x11.cursorPosX = event->xmotion.x;
|
|
||||||
window->x11.cursorPosY = event->xmotion.y;
|
|
||||||
window->x11.cursorCentered = GL_FALSE;
|
window->x11.cursorCentered = GL_FALSE;
|
||||||
|
|
||||||
_glfwInputCursorMotion(window, x, y);
|
_glfwInputCursorMotion(window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window->x11.cursorPosX = event->xmotion.x;
|
||||||
|
window->x11.cursorPosY = event->xmotion.y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,8 +743,8 @@ static void processEvent(XEvent *event)
|
||||||
window = _glfwFindWindowByHandle(data->event);
|
window = _glfwFindWindowByHandle(data->event);
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
if (data->event_x != window->x11.cursorPosX ||
|
if (data->event_x != window->x11.warpPosX ||
|
||||||
data->event_y != window->x11.cursorPosY)
|
data->event_y != window->x11.warpPosY)
|
||||||
{
|
{
|
||||||
// The cursor was moved by something other than GLFW
|
// The cursor was moved by something other than GLFW
|
||||||
|
|
||||||
|
@ -765,12 +764,12 @@ static void processEvent(XEvent *event)
|
||||||
y = data->event_y;
|
y = data->event_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->x11.cursorPosX = data->event_x;
|
|
||||||
window->x11.cursorPosY = data->event_y;
|
|
||||||
window->x11.cursorCentered = GL_FALSE;
|
window->x11.cursorCentered = GL_FALSE;
|
||||||
|
|
||||||
_glfwInputCursorMotion(window, x, y);
|
_glfwInputCursorMotion(window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window->x11.cursorPosX = data->event_x;
|
||||||
|
window->x11.cursorPosY = data->event_y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1094,8 +1093,8 @@ void _glfwPlatformWaitEvents(void)
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
// Store the new position so it can be recognized later
|
// Store the new position so it can be recognized later
|
||||||
window->x11.cursorPosX = x;
|
window->x11.warpPosX = (int) x;
|
||||||
window->x11.cursorPosY = y;
|
window->x11.warpPosY = (int) y;
|
||||||
|
|
||||||
XWarpPointer(_glfw.x11.display, None, window->x11.handle,
|
XWarpPointer(_glfw.x11.display, None, window->x11.handle,
|
||||||
0,0,0,0, (int) x, (int) y);
|
0,0,0,0, (int) x, (int) y);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user