summaryrefslogtreecommitdiff
path: root/x-window-list.c
diff options
context:
space:
mode:
authorPatrick Haller <patrick_haller@ofs.edu.sg>2011-11-09 11:34:34 +0800
committerPatrick Haller <patrick_haller@ofs.edu.sg>2011-11-09 11:34:34 +0800
commitd4e2361215ba3288d4ed71dabdc9a7399654db49 (patch)
treea62b105303861aa1ae5bbafca935e32ca340143f /x-window-list.c
parentd8237405dd8cecd3f8f313131e8c214b123b2948 (diff)
style cleanup - switched to pointer math
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);
}
}