#include #include #include #include #include #include int main(int argc, char **argv) { Display *display; Window target, root, child, parent, *children; int x, y; unsigned int width, height, border, depth, nchildren; if (argc != 2) { char *name; name = strrchr(argv[0], '/'); name = name ? name+1 : argv[0]; fprintf(stderr, "usage: %s window-id\n", name); exit(1); } target = strtol(argv[1], NULL, 10); if ((display = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "cannot open display\n"); exit(1); } XGetGeometry( display, target, &root, &x, &y, &width, &height, &border, &depth); XQueryTree(display, target, &root, &parent, &children, &nchildren); if (children != NULL) XFree(children); if (parent == None) parent = target; XTranslateCoordinates( display, parent, root, x, y, &x, &y, &child); printf("%d %d %u %u\n", x, y, width, height); XCloseDisplay(display); exit(0); }