diff --git a/src/x11_window.c b/src/x11_window.c index 73cc8609..247d2c18 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -740,12 +740,14 @@ static void processEvent(XEvent *event) // and update the mouse position int absX = (event->xclient.data.l[2]>>16) & 0xFFFF; int absY = (event->xclient.data.l[2]) & 0xFFFF; - int x; - int y; - _glfwPlatformGetWindowPos(window,&x,&y); + Window child; + int x, y; - _glfwInputCursorMotion(window,absX-x,absY-y); + XTranslateCoordinates(_glfw.x11.display, _glfw.x11.root, window->x11.handle, + absX, absY, &x, &y, &child); + + _glfwInputCursorMotion(window,x,y); // Xdnd: reply with an XDND status message XClientMessageEvent m; @@ -1093,14 +1095,21 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) { Window child; int x, y; + int left; + int top; - XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root, + + XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root, 0, 0, &x, &y, &child); + XTranslateCoordinates(_glfw.x11.display, window->x11.handle, child, + 0, 0, &left, &top, &child); + + if (xpos) *xpos = x; if (ypos) - *ypos = y; + *ypos = y-top; } void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)