--- a/dwm.c 2012-12-05 06:21:10.873792831 +0100 +++ b/dwm.c 2012-12-05 06:20:44.233791085 +0100 @@ -162,6 +162,7 @@ static void arrange(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); +static void attachaslast(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); @@ -421,6 +422,19 @@ } void +attachaslast(Client *c) { + if(!c->mon->clients) { + c->next = c->mon->clients; + c->mon->clients = c; + return; + } + Client *at; + for(at = c->mon->clients; at->next; at = at->next); + c->next = at->next; + at->next = c; +} + +void attachstack(Client *c) { c->snext = c->mon->stack; c->mon->stack = c; @@ -1163,7 +1177,7 @@ c->isfloating = c->oldstate = trans != None || c->isfixed; if(c->isfloating) XRaiseWindow(dpy, c->win); - attach(c); + attachaslast(c); attachstack(c); XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (unsigned char *) &(c->win), 1);