X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=view.c;h=cb92eee58a973850dc3df0c3fea79c7d7d9d518f;hb=cc05093b0dc2c760a6abfca2756d9c95bba81aa7;hp=3270160d2e1d72022c728d66dba7f50cc4eeba2f;hpb=9d739090750ffb3b3a64e86e2331215b8901c360;p=dwm.git diff --git a/view.c b/view.c index 3270160..cb92eee 100644 --- a/view.c +++ b/view.c @@ -3,31 +3,39 @@ * See LICENSE file for license details. */ #include "dwm.h" +#include /* static */ +static Client * +minclient() +{ + Client *c, *min; + + for(min = c = clients; c; c = c->next) + if(c->weight < min->weight) + min = c; + return min; +} + + static void reorder() { - Client *c, *orig, *p; - - orig = clients; - clients = NULL; + Client *c, *newclients, *tail; - while((c = orig)) { - orig = orig->next; + newclients = tail = NULL; + while((c = minclient())) { detach(c); - - for(p = clients; p && p->next && p->weight <= c->weight; p = p->next); - c->prev = p; - if(p) { - if((c->next = p->next)) - c->next->prev = c; - p->next = c; + if(tail) { + c->prev = tail; + tail->next = c; + tail = c; } else - clients = c; + tail = newclients = c; } + clients = newclients; } /* extern */ @@ -51,8 +59,9 @@ dofloat(Arg *arg) { Client *c; + maximized = False; + for(c = clients; c; c = c->next) { - c->ismax = False; if(isvisible(c)) { resize(c, True, TopLeft); } @@ -60,11 +69,7 @@ dofloat(Arg *arg) ban(c); } if(!sel || !isvisible(sel)) - sel = getnext(clients); - if(sel) - focus(sel); - else - XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + focus(getnext(clients)); restack(); } @@ -74,6 +79,8 @@ dotile(Arg *arg) int h, i, n, w; Client *c; + maximized = False; + w = sw - mw; for(n = 0, c = clients; c; c = c->next) if(isvisible(c) && !c->isfloat) @@ -85,7 +92,6 @@ dotile(Arg *arg) h = sh - bh; for(i = 0, c = clients; c; c = c->next) { - c->ismax = False; if(isvisible(c)) { if(c->isfloat) { resize(c, True, TopLeft); @@ -125,11 +131,7 @@ dotile(Arg *arg) ban(c); } if(!sel || !isvisible(sel)) - sel = getnext(clients); - if(sel) - focus(sel); - else - XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + focus(getnext(clients)); restack(); } @@ -257,7 +259,6 @@ void view(Arg *arg) { unsigned int i; - Client *c; for(i = 0; i < ntags; i++) seltag[i] = False; @@ -267,11 +268,22 @@ view(Arg *arg) } void +viewall(Arg *arg) +{ + unsigned int i; + + for(i = 0; i < ntags; i++) + seltag[i] = True; + reorder(); + arrange(NULL); +} + +void zoom(Arg *arg) { Client *c = sel; - if(!c || (arrange != dotile) || c->isfloat || c->ismax) + if(!c || (arrange != dotile) || c->isfloat || maximized) return; if(c == getnext(clients))