x11_window: use XTranslateCoordiantes to get correct coordiantes

for XdndPosition
This commit is contained in:
arturo 2013-07-10 15:55:55 +02:00
parent af115856d4
commit cc9730d8a6

View File

@ -740,12 +740,14 @@ static void processEvent(XEvent *event)
// and update the mouse position // and update the mouse position
int absX = (event->xclient.data.l[2]>>16) & 0xFFFF; int absX = (event->xclient.data.l[2]>>16) & 0xFFFF;
int absY = (event->xclient.data.l[2]) & 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 // Xdnd: reply with an XDND status message
XClientMessageEvent m; XClientMessageEvent m;
@ -1093,14 +1095,21 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{ {
Window child; Window child;
int x, y; 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); 0, 0, &x, &y, &child);
XTranslateCoordinates(_glfw.x11.display, window->x11.handle, child,
0, 0, &left, &top, &child);
if (xpos) if (xpos)
*xpos = x; *xpos = x;
if (ypos) if (ypos)
*ypos = y; *ypos = y-top;
} }
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)