diff options
| author | Patrick Haller <patrick@haller.ws> | 2012-02-18 14:37:18 +0800 |
|---|---|---|
| committer | Patrick Haller <patrick@haller.ws> | 2012-02-18 14:37:18 +0800 |
| commit | c0f8a57194fbdecc2870de7594edf2e47c557baa (patch) | |
| tree | dea2c08eff25e79184fa025a5c9a175754dbae2a /x-window-list.c | |
| parent | 7fa1169cb63c8a795782446863794e5349f019a7 (diff) | |
| parent | a1ef548bfb93e95b62369fc80a352832eff9bf50 (diff) | |
Merge branch 'master' of github.com:patrickhaller/no-wm
Diffstat (limited to 'x-window-list.c')
| -rw-r--r-- | x-window-list.c | 17 |
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); } } |
