summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README2
-rw-r--r--x-alt-tab.c8
-rw-r--r--x-window-list.c17
3 files changed, 15 insertions, 12 deletions
diff --git a/README b/README
index b2de438..1b10f4b 100644
--- a/README
+++ b/README
@@ -19,6 +19,8 @@ components
unclutter http://unclutter.sourceforge.net/
dmenu http://tools.suckless.org/dmenu/
autocutsel http://www.nongnu.org/autocutsel/
+ overview
+ http://www.sbin.org/doc/Xlib/index_contents.html
procedure
set up your ${HOME}/.xinitrc to be something like
diff --git a/x-alt-tab.c b/x-alt-tab.c
index 25976e0..de4cd6e 100644
--- a/x-alt-tab.c
+++ b/x-alt-tab.c
@@ -4,13 +4,15 @@ int main(int argc, char **argv)
{
Display *dpy;
- if(!(dpy = XOpenDisplay(0x0))) return 1;
+ if ( (dpy = XOpenDisplay(NULL)) == NULL)
+ return 1;
+
if (argc > 1)
XCirculateSubwindowsDown(dpy, DefaultRootWindow(dpy));
else
XCirculateSubwindowsUp(dpy, DefaultRootWindow(dpy));
- XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); /* nuke focus back to pointer */
+
+ XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XSync(dpy, True);
return 0;
}
-
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);
}
}