summaryrefslogtreecommitdiff
path: root/x-window-list.c
diff options
context:
space:
mode:
authorPatrick Haller <patrick@haller.ws>2012-02-18 14:37:18 +0800
committerPatrick Haller <patrick@haller.ws>2012-02-18 14:37:18 +0800
commitc0f8a57194fbdecc2870de7594edf2e47c557baa (patch)
treedea2c08eff25e79184fa025a5c9a175754dbae2a /x-window-list.c
parent7fa1169cb63c8a795782446863794e5349f019a7 (diff)
parenta1ef548bfb93e95b62369fc80a352832eff9bf50 (diff)
Merge branch 'master' of github.com:patrickhaller/no-wm
Diffstat (limited to 'x-window-list.c')
-rw-r--r--x-window-list.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/x-window-list.c b/x-window-list.c
index b899584..34528f7 100644
--- a/x-window-list.c
+++ b/x-window-list.c
@@ -6,24 +6,23 @@
// first window listed is top-most, last is bottom-most in window-stacking
int main(void) {
Display *dpy;
- Window root;
- Window parent;
- Window *wins;
+ Window root, parent, *wins, *w;
unsigned int nwins;
- if(!(dpy = XOpenDisplay(NULL)))
+ if ((dpy = XOpenDisplay(NULL)) == NULL)
return 1;
+
XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins);
- for (int i=nwins-1; i >= 0; i--) {
+ for (w = wins + nwins - 1; w >= wins; w--) {
XTextProperty name;
XClassHint hint;
XWindowAttributes attr;
- XGetClassHint(dpy, wins[i], &hint);
- XGetWMName(dpy, wins[i], &name);
- XGetWindowAttributes(dpy, wins[i], &attr);
+ XGetClassHint(dpy, *w, &hint);
+ XGetWMName(dpy, *w, &name);
+ XGetWindowAttributes(dpy, *w, &attr);
if (attr.map_state == IsViewable)
- fprintf(stdout, "0x%-10x %s - %s\n", (unsigned int)wins[i], hint.res_name, name.value);
+ printf("0x%-10x %s - %s\n", (unsigned int)*w, hint.res_name, name.value);
}
}