dwm-meillo

diff view.c @ 378:83576f5f0a90

added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
author Anselm R. Garbe <arg@10kloc.org>
date Tue, 29 Aug 2006 09:23:44 +0200
parents a1901753deef
children 4bf79305d675
line diff
     1.1 --- a/view.c	Mon Aug 28 14:32:51 2006 +0200
     1.2 +++ b/view.c	Tue Aug 29 09:23:44 2006 +0200
     1.3 @@ -9,6 +9,45 @@
     1.4  void (*arrange)(Arg *) = DEFMODE;
     1.5  
     1.6  void
     1.7 +attach(Client *c)
     1.8 +{
     1.9 +	Client *first = getnext(clients);
    1.10 +
    1.11 +	if(!first) {
    1.12 +		if(clients) {
    1.13 +			for(first = clients; first->next; first = first->next);
    1.14 +			first->next = c;
    1.15 +			c->prev = first;
    1.16 +		}
    1.17 +		else
    1.18 +			clients = c;
    1.19 +	}
    1.20 +	else if(first == clients) {
    1.21 +		c->next = clients;
    1.22 +		clients->prev = c;
    1.23 +		clients = c;
    1.24 +	}
    1.25 +	else {
    1.26 +		first->prev->next = c;
    1.27 +		c->prev = first->prev;
    1.28 +		first->prev = c;
    1.29 +		c->next = first;
    1.30 +	}
    1.31 +}
    1.32 +
    1.33 +void
    1.34 +detach(Client *c)
    1.35 +{
    1.36 +	if(c->prev)
    1.37 +		c->prev->next = c->next;
    1.38 +	if(c->next)
    1.39 +		c->next->prev = c->prev;
    1.40 +	if(c == clients)
    1.41 +		clients = c->next;
    1.42 +	c->next = c->prev = NULL;
    1.43 +}
    1.44 +
    1.45 +void
    1.46  dofloat(Arg *arg)
    1.47  {
    1.48  	Client *c;
    1.49 @@ -228,26 +267,16 @@
    1.50  void
    1.51  zoom(Arg *arg)
    1.52  {
    1.53 -	Client *c;
    1.54 +	Client *c = sel;
    1.55  
    1.56 -	if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
    1.57 +	if(!c || (arrange != dotile) || c->isfloat || c->ismax)
    1.58  		return;
    1.59  
    1.60 -	if(sel == getnext(clients))  {
    1.61 -		if((c = getnext(sel->next)))
    1.62 -			sel = c;
    1.63 -		else
    1.64 +	if(c == getnext(clients))
    1.65 +		if(!(c = getnext(c->next)))
    1.66  			return;
    1.67 -	}
    1.68 -
    1.69 -	/* pop */
    1.70 -	sel->prev->next = sel->next;
    1.71 -	if(sel->next)
    1.72 -		sel->next->prev = sel->prev;
    1.73 -	sel->prev = NULL;
    1.74 -	clients->prev = sel;
    1.75 -	sel->next = clients;
    1.76 -	clients = sel;
    1.77 -	focus(sel);
    1.78 +	detach(c);
    1.79 +	attach(c);
    1.80 +	focus(c);
    1.81  	arrange(NULL);
    1.82  }