1
0

still something wrong with reorder()

This commit is contained in:
Anselm R. Garbe 2006-08-29 13:40:09 +02:00
parent 016c54196e
commit 9d73909075
4 changed files with 32 additions and 55 deletions

View File

@ -241,7 +241,10 @@ manage(Window w, XWindowAttributes *wa)
|| (c->maxw && c->minw && || (c->maxw && c->minw &&
c->maxw == c->minw && c->maxh == c->minh); c->maxw == c->minw && c->maxh == c->minh);
attach(c); if(clients)
clients->prev = c;
c->next = clients;
clients = c;
settitle(c); settitle(c);
if(isvisible(c)) if(isvisible(c))

3
dwm.h
View File

@ -56,7 +56,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int grav; int grav;
long flags; long flags;
unsigned int border; unsigned int border, weight;
Bool isfloat; Bool isfloat;
Bool ismax; Bool ismax;
Bool *tags; Bool *tags;
@ -127,7 +127,6 @@ extern void *erealloc(void *ptr, unsigned int size);
extern void spawn(Arg *arg); extern void spawn(Arg *arg);
/* view.c */ /* view.c */
extern void attach(Client *c);
extern void detach(Client *c); extern void detach(Client *c);
extern void dofloat(Arg *arg); extern void dofloat(Arg *arg);
extern void dotile(Arg *arg); extern void dotile(Arg *arg);

6
tag.c
View File

@ -106,6 +106,8 @@ settags(Client *c)
if(!matched) if(!matched)
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
c->tags[i] = seltag[i]; c->tags[i] = seltag[i];
for(i = 0; i < ntags && !c->tags[i]; i++);
c->weight = i;
} }
void void
@ -120,8 +122,6 @@ tag(Arg *arg)
sel->tags[i] = False; sel->tags[i] = False;
sel->tags[arg->i] = True; sel->tags[arg->i] = True;
settitle(sel); settitle(sel);
detach(sel);
attach(sel);
if(!isvisible(sel)) if(!isvisible(sel))
arrange(NULL); arrange(NULL);
else else
@ -141,8 +141,6 @@ toggletag(Arg *arg)
if(i == ntags) if(i == ntags)
sel->tags[arg->i] = True; sel->tags[arg->i] = True;
settitle(sel); settitle(sel);
detach(sel);
attach(sel);
if(!isvisible(sel)) if(!isvisible(sel))
arrange(NULL); arrange(NULL);
else else

73
view.c
View File

@ -6,62 +6,34 @@
/* static */ /* static */
static Client * static void
getslot(Client *c) reorder()
{ {
unsigned int i, tic; Client *c, *orig, *p;
Client *p;
for(tic = 0; tic < ntags && !c->tags[tic]; tic++); orig = clients;
for(p = clients; p; p = p->next) { clients = NULL;
for(i = 0; i < ntags && !p->tags[i]; i++);
if(tic < i)
return p;
}
return p;
}
static Client * while((c = orig)) {
tail() orig = orig->next;
{ detach(c);
Client *c;
for(c = clients; c && c->next; c = c->next); for(p = clients; p && p->next && p->weight <= c->weight; p = p->next);
return c; c->prev = p;
if(p) {
if((c->next = p->next))
c->next->prev = c;
p->next = c;
}
else
clients = c;
}
} }
/* extern */ /* extern */
void (*arrange)(Arg *) = DEFMODE; 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 void
detach(Client *c) detach(Client *c)
{ {
@ -277,6 +249,7 @@ toggleview(Arg *arg)
for(i = 0; i < ntags && !seltag[i]; i++); for(i = 0; i < ntags && !seltag[i]; i++);
if(i == ntags) if(i == ntags)
seltag[arg->i] = True; /* cannot toggle last view */ seltag[arg->i] = True; /* cannot toggle last view */
reorder();
arrange(NULL); arrange(NULL);
} }
@ -284,10 +257,12 @@ void
view(Arg *arg) view(Arg *arg)
{ {
unsigned int i; unsigned int i;
Client *c;
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
seltag[i] = False; seltag[i] = False;
seltag[arg->i] = True; seltag[arg->i] = True;
reorder();
arrange(NULL); arrange(NULL);
} }
@ -303,7 +278,9 @@ zoom(Arg *arg)
if(!(c = getnext(c->next))) if(!(c = getnext(c->next)))
return; return;
detach(c); detach(c);
attach(c); c->next = clients;
clients->prev = c;
clients = c;
focus(c); focus(c);
arrange(NULL); arrange(NULL);
} }