diff --git a/dwm.c b/dwm.c index ec6a27c..40e46bf 100644 --- a/dwm.c +++ b/dwm.c @@ -407,6 +407,20 @@ attach(Client *c) c->mon->clients = c; } +void +attachabove(Client *c) +{ + if(c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) { + attach(c); + return; + } + + Client *at; + for(at = c->mon->clients; at->next != c->mon->sel; at = at->next); + c->next = at->next; + at->next = c; +} + void attachstack(Client *c) { @@ -1204,7 +1218,7 @@ void pop(Client *c) { detach(c); - attach(c); + attachabove(c); focus(c); arrange(c->mon); } @@ -1418,7 +1432,7 @@ sendmon(Client *c, Monitor *m) detachstack(c); c->mon = m; c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ - attach(c); + attachabove(c); attachstack(c); focus(NULL); arrange(NULL); @@ -1898,7 +1912,7 @@ updategeom(void) m->clients = c->next; detachstack(c); c->mon = mons; - attach(c); + attachabove(c); attachstack(c); } if (m == selmon)