summaryrefslogtreecommitdiff
path: root/x-alt-tab.c
diff options
context:
space:
mode:
Diffstat (limited to 'x-alt-tab.c')
-rw-r--r--x-alt-tab.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/x-alt-tab.c b/x-alt-tab.c
index 66ce6ea..c5acc16 100644
--- a/x-alt-tab.c
+++ b/x-alt-tab.c
@@ -15,45 +15,45 @@ If not, see http://creativecommons.org/publicdomain/zero/1.0/ */
typedef enum RotationEnum { bottom_to_top, top_to_bottom } Rotation;
void x_alt_tab(Rotation r, Display *dpy, Window *wins, unsigned int nwins) {
- Window *viewables[nwins], *w = 0;
- unsigned int vc = 0;
-
- // make list of viewable windows
- XWindowAttributes attr;
- for (w = wins; w - wins < nwins; w++) {
- XGetWindowAttributes(dpy, *w, &attr);
- if (attr.map_state == IsViewable)
- viewables[vc++] = w;
- }
- viewables[vc] = NULL;
-
- // promote the bottom to top, or demote top to bottom and raise 2nd
- if (r == bottom_to_top)
- w = viewables[0];
- else {
- XLowerWindow(dpy, *(viewables[vc - 1]));
- w = viewables[vc - 2];
- }
-
- XRaiseWindow(dpy, *w);
- XSetInputFocus(dpy, *w, RevertToPointerRoot, CurrentTime);
- XSync(dpy, True);
+ Window *viewables[nwins], *w = 0;
+ unsigned int vc = 0;
+
+ // make list of viewable windows
+ XWindowAttributes attr;
+ for (w = wins; w - wins < nwins; w++) {
+ XGetWindowAttributes(dpy, *w, &attr);
+ if (attr.map_state == IsViewable)
+ viewables[vc++] = w;
+ }
+ viewables[vc] = NULL;
+
+ // promote the bottom to top, or demote top to bottom and raise 2nd
+ if (r == bottom_to_top)
+ w = viewables[0];
+ else {
+ XLowerWindow(dpy, *(viewables[vc - 1]));
+ w = viewables[vc - 2];
+ }
+
+ XRaiseWindow(dpy, *w);
+ XSetInputFocus(dpy, *w, RevertToPointerRoot, CurrentTime);
+ XSync(dpy, True);
}
int main(int argc, char **argv) {
- Display *dpy;
- unsigned int nwins = 0;
- Window root, parent, *wins = 0;
+ Display *dpy;
+ unsigned int nwins = 0;
+ Window root, parent, *wins = 0;
- if ( (dpy = XOpenDisplay(NULL)) == NULL)
- return 1;
+ if ( (dpy = XOpenDisplay(NULL)) == NULL)
+ return 1;
- XSync(dpy, True);
- XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins);
- if (nwins <= 1)
- return 0;
+ XSync(dpy, True);
+ XQueryTree(dpy, DefaultRootWindow(dpy), &root, &parent, &wins, &nwins);
+ if (nwins <= 1)
+ return 0;
- Rotation r = (argc == 1) ? bottom_to_top : top_to_bottom;
- x_alt_tab(r, dpy, wins, nwins);
- return 0;
+ Rotation r = (argc == 1) ? bottom_to_top : top_to_bottom;
+ x_alt_tab(r, dpy, wins, nwins);
+ return 0;
}