dwm-meillo

diff view.c @ 650:f3b8c71a69d4

experimental version which allows master clients being increased/decreased
author Anselm R. Garbe <arg@suckless.org>
date Fri, 05 Jan 2007 12:50:39 +0100
parents 1ed8c40dde36
children b9f4efd21473
line diff
     1.1 --- a/view.c	Thu Jan 04 16:45:28 2007 +0100
     1.2 +++ b/view.c	Fri Jan 05 12:50:39 2007 +0100
     1.3 @@ -69,12 +69,16 @@
     1.4  
     1.5  void
     1.6  dotile(void) {
     1.7 -	unsigned int i, n, mpw, th;
     1.8 +	unsigned int i, n, mw, mh, tw, th;
     1.9  	Client *c;
    1.10  
    1.11  	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    1.12  		n++;
    1.13 -	mpw = (waw * master) / 1000;
    1.14 +	/* window geoms */
    1.15 +	mw = (n > nmaster) ? (waw * master) / 1000 : waw;
    1.16 +	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
    1.17 +	tw = waw - mw;
    1.18 +	th = (n > nmaster) ? wah / (n - nmaster) : 0;
    1.19  
    1.20  	for(i = 0, c = clients; c; c = c->next)
    1.21  		if(isvisible(c)) {
    1.22 @@ -85,20 +89,16 @@
    1.23  			c->ismax = False;
    1.24  			c->x = wax;
    1.25  			c->y = way;
    1.26 -			if(n == 1) { /* only 1 window */
    1.27 -				c->w = waw - 2 * BORDERPX;
    1.28 -				c->h = wah - 2 * BORDERPX;
    1.29 -			}
    1.30 -			else if(i == 0) { /* master window */
    1.31 -				c->w = mpw - 2 * BORDERPX;
    1.32 -				c->h = wah - 2 * BORDERPX;
    1.33 -				th = wah / (n - 1);
    1.34 +			if(i < nmaster) {
    1.35 +				c->y += i * mh;
    1.36 +				c->w = mw - 2 * BORDERPX;
    1.37 +				c->h = mh - 2 * BORDERPX;
    1.38  			}
    1.39  			else {  /* tile window */
    1.40 -				c->x += mpw;
    1.41 -				c->w = (waw - mpw) - 2 * BORDERPX;
    1.42 +				c->x += mw;
    1.43 +				c->w = tw - 2 * BORDERPX;
    1.44  				if(th > bh) {
    1.45 -					c->y += (i - 1) * th;
    1.46 +					c->y += (i - nmaster) * th;
    1.47  					c->h = th - 2 * BORDERPX;
    1.48  				}
    1.49  				else /* fallback if th < bh */
    1.50 @@ -147,6 +147,14 @@
    1.51  	}
    1.52  }
    1.53  
    1.54 +void
    1.55 +incnmaster(Arg *arg) {
    1.56 +	if(nmaster + arg->i < 1)
    1.57 +		return;
    1.58 +	nmaster += arg->i;
    1.59 +	arrange();
    1.60 +}
    1.61 +
    1.62  Bool
    1.63  isvisible(Client *c) {
    1.64  	unsigned int i;
    1.65 @@ -240,7 +248,7 @@
    1.66  
    1.67  void
    1.68  zoom(Arg *arg) {
    1.69 -	unsigned int n;
    1.70 +	unsigned int i, n;
    1.71  	Client *c;
    1.72  
    1.73  	if(!sel)
    1.74 @@ -249,14 +257,19 @@
    1.75  		togglemax(sel);
    1.76  		return;
    1.77  	}
    1.78 -	for(n = 0, c = clients; c; c = c->next)
    1.79 -		if(isvisible(c) && !c->isfloat)
    1.80 -			n++;
    1.81 -	if(n < 2 || (arrange == dofloat))
    1.82 +	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    1.83 +		n++;
    1.84 +	if(n <= nmaster || (arrange == dofloat))
    1.85  		return;
    1.86 -	if((c = sel) == nexttiled(clients))
    1.87 -		if(!(c = nexttiled(c->next)))
    1.88 -			return;
    1.89 +
    1.90 +	for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
    1.91 +		i++;
    1.92 +	if(c == sel && i < nmaster)
    1.93 +		for(; c && i < nmaster; c = nexttiled(c->next))
    1.94 +			i++;
    1.95 +	if(!c)
    1.96 +		return;
    1.97 +
    1.98  	detach(c);
    1.99  	if(clients)
   1.100  		clients->prev = c;