From df8a36baebb8003f5173965ceaf356ad43c0b95d Mon Sep 17 00:00:00 2001 From: Felipe Ferreira da Silva Date: Fri, 7 Apr 2017 21:54:36 -0300 Subject: [PATCH] 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. --- src/x11_window.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 80f9f46c5..f83f44d57 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -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;