- Window root, parent, *kids;
- unsigned int nkids;
- XWindowAttributes xgwa;
- int wx, wy;
- XGetWindowAttributes (dpy, window, &xgwa);
-
- wx = xgwa.x;
- wy = xgwa.y;
-
- kids = 0;
- *x = 0;
- *y = 0;
-
- if (XQueryTree (dpy, window, &root, &parent, &kids, &nkids))
- {
- if (parent && parent != root)
- {
- int px, py;
- window_origin (dpy, parent, &px, &py);
- wx += px;
- wy += py;
- }
- }
- if (kids) XFree (kids);
- *x = wx;
- *y = wy;
+ XTranslateCoordinates (dpy, window, RootWindow (dpy, DefaultScreen (dpy)),
+ 0, 0, x, y, &window);