#include #include #include #include static void walk(Display *d, Window w, int depth) { Window root, parent, *children = NULL; unsigned int n = 0, i; char *name = NULL; if (XFetchName(d, w, &name) && name) { if (strstr(name, "Dillo") || strstr(name, "Site is online")) printf("%.*s%s\n", depth * 2, " ", name); XFree(name); } if (XQueryTree(d, w, &root, &parent, &children, &n)) { for (i = 0; i < n; i++) walk(d, children[i], depth + 1); if (children) XFree(children); } } int main(void) { Display *d = XOpenDisplay(NULL); if (!d) { fputs("XOpenDisplay failed\n", stderr); return 1; } walk(d, DefaultRootWindow(d), 0); XCloseDisplay(d); return 0; }