From 3fbb7c6e9823052e6b3492ad96baae51f19a07b7 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 9 Oct 2015 01:41:10 +0800 Subject: add set focus to x-alt-tab --- x-alt-tab.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x-alt-tab.c b/x-alt-tab.c index 2d61036..180e227 100644 --- a/x-alt-tab.c +++ b/x-alt-tab.c @@ -10,31 +10,34 @@ If not, see http://creativecommons.org/publicdomain/zero/1.0/ */ #include #include +#include int main(int argc, char **argv) { Display *dpy; XWindowAttributes attr; unsigned int nwins, count = 0; + Window root, parent, *wins, *w = 0; if ( (dpy = XOpenDisplay(NULL)) == NULL) return 1; do { - Window root, parent, *wins, *w; - if (argc > 1) XCirculateSubwindowsDown(dpy, DefaultRootWindow(dpy)); else XCirculateSubwindowsUp(dpy, DefaultRootWindow(dpy)); - XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, True); XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins); w = wins + nwins - 1; XGetWindowAttributes(dpy, *w, &attr); count++; + } while (attr.map_state != IsViewable && count <= nwins+1); + XSetInputFocus(dpy, *w, RevertToParent, CurrentTime); + XSync(dpy, True); + return 0; } -- cgit v1.2.3