+
+ /* try to get through _NET_FRAME_EXTENTS */
+ net_extents = XInternAtom(fgDisplay.pDisplay.Display, "_NET_FRAME_EXTENTS", False);
+
+ result = XGetWindowProperty(
+ fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, net_extents,
+ 0, 4, False, AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &data);
+
+ if (result == Success && nitems == 4 && bytes_after == 0)
+ /* got the data we expected, here's to hoping that
+ * _NET_FRAME_EXTENTS is supported and the data
+ * contain sensible values */
+ {
+ long *extents = (long *)data;
+ left = (int) extents[0]; /* we take left as border width, consistent with old logic. bottom and right better be the same... */
+ top = (int) extents[2];
+ }
+ else
+ {
+ /* try in the previous way as fall-back */
+ Window w;
+ int x,y;
+
+ XTranslateCoordinates(
+ fgDisplay.pDisplay.Display,
+ fgStructure.CurrentWindow->Window.Handle,
+ fgDisplay.pDisplay.RootWindow,
+ 0, 0, &x, &y, &w);
+
+ if (w == 0)
+ /* logic below needs w */
+ return 0;
+
+ XTranslateCoordinates(
+ fgDisplay.pDisplay.Display,
+ fgStructure.CurrentWindow->Window.Handle,
+ w, 0, 0, &x, &y, &w);
+
+ left = x;
+ top = y;
+ }
+ if (result == Success)
+ XFree(data);