X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=view.c;h=9ba8e0bcd541c17b54b44b97e3f3b4474d822749;hb=8a6679b3b4999559059df3ae9e08951099511036;hp=d9aa6e4a2f328974c98fddb4c1cdf0de20e3c46b;hpb=aa13727067af829b94461eb36aa029297ed8e6b9;p=dwm.git diff --git a/view.c b/view.c index d9aa6e4..9ba8e0b 100644 --- a/view.c +++ b/view.c @@ -9,6 +9,45 @@ void (*arrange)(Arg *) = DEFMODE; void +attach(Client *c) +{ + Client *first = getnext(clients); + + if(!first) { + if(clients) { + for(first = clients; first->next; first = first->next); + first->next = c; + c->prev = first; + } + else + clients = c; + } + else if(first == clients) { + c->next = clients; + clients->prev = c; + clients = c; + } + else { + first->prev->next = c; + c->prev = first->prev; + first->prev = c; + c->next = first; + } +} + +void +detach(Client *c) +{ + if(c->prev) + c->prev->next = c->next; + if(c->next) + c->next->prev = c->prev; + if(c == clients) + clients = c->next; + c->next = c->prev = NULL; +} + +void dofloat(Arg *arg) { Client *c; @@ -168,21 +207,21 @@ restack() fi = 0; mi = 2 * f; if(sel->isfloat || arrange == dofloat) { - wins[fi++] = sel->title; + wins[fi++] = sel->twin; wins[fi++] = sel->win; } else { - wins[mi++] = sel->title; + wins[mi++] = sel->twin; wins[mi++] = sel->win; } for(c = clients; c; c = c->next) if(isvisible(c) && c != sel) { if(c->isfloat || arrange == dofloat) { - wins[fi++] = c->title; + wins[fi++] = c->twin; wins[fi++] = c->win; } else { - wins[mi++] = c->title; + wins[mi++] = c->twin; wins[mi++] = c->win; } } @@ -195,7 +234,7 @@ restack() void togglemode(Arg *arg) { - arrange = arrange == dofloat ? dotile : dofloat; + arrange = (arrange == dofloat) ? dotile : dofloat; if(sel) arrange(NULL); else @@ -228,26 +267,16 @@ view(Arg *arg) void zoom(Arg *arg) { - Client *c; + Client *c = sel; - if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax) + if(!c || (arrange != dotile) || c->isfloat || c->ismax) return; - if(sel == getnext(clients)) { - if((c = getnext(sel->next))) - sel = c; - else + if(c == getnext(clients)) + if(!(c = getnext(c->next))) return; - } - - /* pop */ - sel->prev->next = sel->next; - if(sel->next) - sel->next->prev = sel->prev; - sel->prev = NULL; - clients->prev = sel; - sel->next = clients; - clients = sel; - focus(sel); + detach(c); + attach(c); + focus(c); arrange(NULL); }