summaryrefslogtreecommitdiff
path: root/x-window-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'x-window-list.c')
-rw-r--r--x-window-list.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/x-window-list.c b/x-window-list.c
new file mode 100644
index 0000000..a9c1381
--- /dev/null
+++ b/x-window-list.c
@@ -0,0 +1,23 @@
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+// http://tronche.com/gui/x/xlib/
+// first window listed is top-most, last is bottom-most in window-stacking
+int main(void) {
+ Display *dpy;
+ Window root;
+ Window parent;
+ Window *wins;
+ XClassHint hint;
+ unsigned int nwins;
+
+ if(!(dpy = XOpenDisplay(NULL)))
+ return 1;
+ XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins);
+
+ for (int i=nwins-1; i >= 0; i--) {
+ XGetClassHint(dpy, wins[i], &hint);
+ fprintf(stderr, "0x%-10x %s\n", (unsigned int)wins[i], hint.res_name);
+ }
+}