all repos — dwm @ 9d739090750ffb3b3a64e86e2331215b8901c360

my dwm build

still something wrong with reorder()
Anselm R. Garbe arg@10kloc.org
Tue, 29 Aug 2006 13:40:09 +0200
commit

9d739090750ffb3b3a64e86e2331215b8901c360

parent

016c54196e682ae8658854febb746b0437a010dc

4 files changed, 32 insertions(+), 55 deletions(-)

jump to
M client.cclient.c

@@ -241,7 +241,10 @@ c->isfloat = trans

|| (c->maxw && c->minw && c->maxw == c->minw && c->maxh == c->minh); - attach(c); + if(clients) + clients->prev = c; + c->next = clients; + clients = c; settitle(c); if(isvisible(c))
M dwm.hdwm.h

@@ -56,7 +56,7 @@ int tx, ty, tw, th; /* title */

int basew, baseh, incw, inch, maxw, maxh, minw, minh; int grav; long flags; - unsigned int border; + unsigned int border, weight; Bool isfloat; Bool ismax; Bool *tags;

@@ -127,7 +127,6 @@ extern void *erealloc(void *ptr, unsigned int size);

extern void spawn(Arg *arg); /* view.c */ -extern void attach(Client *c); extern void detach(Client *c); extern void dofloat(Arg *arg); extern void dotile(Arg *arg);
M tag.ctag.c

@@ -106,6 +106,8 @@ }

if(!matched) for(i = 0; i < ntags; i++) c->tags[i] = seltag[i]; + for(i = 0; i < ntags && !c->tags[i]; i++); + c->weight = i; } void

@@ -120,8 +122,6 @@ for(i = 0; i < ntags; i++)

sel->tags[i] = False; sel->tags[arg->i] = True; settitle(sel); - detach(sel); - attach(sel); if(!isvisible(sel)) arrange(NULL); else

@@ -141,8 +141,6 @@ for(i = 0; i < ntags && !sel->tags[i]; i++);

if(i == ntags) sel->tags[arg->i] = True; settitle(sel); - detach(sel); - attach(sel); if(!isvisible(sel)) arrange(NULL); else
M view.cview.c

@@ -6,61 +6,33 @@ #include "dwm.h"

/* static */ -static Client * -getslot(Client *c) +static void +reorder() { - unsigned int i, tic; - Client *p; + Client *c, *orig, *p; + + orig = clients; + clients = NULL; - for(tic = 0; tic < ntags && !c->tags[tic]; tic++); - for(p = clients; p; p = p->next) { - for(i = 0; i < ntags && !p->tags[i]; i++); - if(tic < i) - return p; - } - return p; -} + while((c = orig)) { + orig = orig->next; + detach(c); -static Client * -tail() -{ - Client *c; - for(c = clients; c && c->next; c = c->next); - return 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; + } + else + clients = c; + } } /* extern */ void (*arrange)(Arg *) = DEFMODE; - -void -attach(Client *c) -{ - Client *p; - - if(!clients) { - clients = c; - return; - } - if(!(p = getnext(clients)) && !(p = getslot(c))) { - p = tail(); - c->prev = p; - p->next = c; - return; - } - - if(p == clients) { - c->next = clients; - clients->prev = c; - clients = c; - } - else { - p->prev->next = c; - c->prev = p->prev; - p->prev = c; - c->next = p; - } -} void detach(Client *c)

@@ -277,6 +249,7 @@ seltag[arg->i] = !seltag[arg->i];

for(i = 0; i < ntags && !seltag[i]; i++); if(i == ntags) seltag[arg->i] = True; /* cannot toggle last view */ + reorder(); arrange(NULL); }

@@ -284,10 +257,12 @@ void

view(Arg *arg) { unsigned int i; + Client *c; for(i = 0; i < ntags; i++) seltag[i] = False; seltag[arg->i] = True; + reorder(); arrange(NULL); }

@@ -303,7 +278,9 @@ if(c == getnext(clients))

if(!(c = getnext(c->next))) return; detach(c); - attach(c); + c->next = clients; + clients->prev = c; + clients = c; focus(c); arrange(NULL); }