Check position of window and cursor before drag

The previous implementation was using the stored window position and the
stored last cursor position, but these should be updated. It's more
reliable to get the current position of the window and cursor, otherwise
the window might "jump" position during the start of a drag operation.
This commit is contained in:
Felipe Ferreira da Silva 2017-04-07 21:54:36 -03:00
parent f3cea803ca
commit df8a36baeb

View File

@ -2094,16 +2094,20 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
void _glfwPlatformDragWindow(_GLFWwindow* window)
{
int winXpos, winYpos;
double curXpos, curYpos;
XClientMessageEvent xclient;
memset(&xclient, 0, sizeof(XClientMessageEvent));
XUngrabPointer(_glfw.x11.display, 0);
XFlush(_glfw.x11.display);
_glfwPlatformGetCursorPos(window, &curXpos, &curYpos);
_glfwPlatformGetWindowPos(window, &winXpos, &winYpos);
xclient.type = ClientMessage;
xclient.window = window->x11.handle;
xclient.message_type = XInternAtom(_glfw.x11.display, "_NET_WM_MOVERESIZE", False);
xclient.format = 32;
xclient.data.l[0] = window->x11.xpos + window->x11.lastCursorPosX;
xclient.data.l[1] = window->x11.ypos + window->x11.lastCursorPosY;
xclient.data.l[0] = winXpos + curXpos;
xclient.data.l[1] = winYpos + curYpos;
xclient.data.l[2] = _NET_WM_MOVERESIZE_MOVE;
xclient.data.l[3] = 0;
xclient.data.l[4] = 0;