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