summaryrefslogtreecommitdiff
path: root/x-window-list.c
diff options
context:
space:
mode:
authorPatrick Haller <patrick@haller.ws>2011-03-15 20:07:54 +0800
committerPatrick Haller <patrick@haller.ws>2011-03-15 20:07:54 +0800
commit61d756ab5bd5eba872a616e2cc9c79036077b7a8 (patch)
tree59e5a44ca554625f79a6db3c29f9fe66b2107b98 /x-window-list.c
parentea30e4af52cf4b17aac63135933c4e0d09725eb3 (diff)
parente6080067a6cc7cceb39503799fff4416017aa410 (diff)
Merge branch 'window-list'
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);
+ }
+}