/* static functions */
+static void
+detachstack(Client *c)
+{
+ Client **tc;
+ for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
+ *tc = c->snext;
+}
+
static void
grabbuttons(Client *c, Bool focus)
{
}
}
if(c) {
+ detachstack(c);
+ c->snext = stack;
+ stack = c;
grabbuttons(c, True);
drawtitle(c);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
void
manage(Window w, XWindowAttributes *wa)
{
- unsigned int i;
Client *c;
Window trans;
XSetWindowAttributes twa;
if(clients)
clients->prev = c;
c->next = clients;
- clients = c;
+ c->snext = stack;
+ stack = clients = c;
settitle(c);
ban(c);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->twin);
+ detachstack(c);
free(c->tags);
free(c);
Bool *tags;
Client *next;
Client *prev;
+ Client *snext;
Window win;
Window twin;
};
extern void (*arrange)(Arg *);
extern Atom wmatom[WMLast], netatom[NetLast];
extern Bool running, issel, maximized, *seltag;
-extern Client *clients, *sel;
+extern Client *clients, *sel, *stack;
extern Cursor cursor[CurLast];
extern DC dc;
extern Display *dpy;
Bool maximized = False;
Client *clients = NULL;
Client *sel = NULL;
+Client *stack = NULL;
Cursor cursor[CurLast];
Display *dpy;
DC dc = {0};
else
ban(c);
}
- if(!sel || !isvisible(sel))
- focus(getnext(clients));
+ if(!sel || !isvisible(sel)) {
+ for(sel = stack; sel && !isvisible(sel); sel = sel->snext);
+ focus(sel);
+ }
restack();
}
else
ban(c);
}
- if(!sel || !isvisible(sel))
- focus(getnext(clients));
+ if(!sel || !isvisible(sel)) {
+ for(sel = stack; sel && !isvisible(sel); sel = sel->snext);
+ focus(sel);
+ }
restack();
}
XRaiseWindow(dpy, sel->win);
XRaiseWindow(dpy, sel->twin);
}
- if(arrange != dofloat)
+ if(arrange != dofloat)
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
XLowerWindow(dpy, c->twin);
XLowerWindow(dpy, c->win);