aewl

diff view.c @ 507:2824b5d0f0f0

prelim of dotile()
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 29 Sep 2006 14:39:03 +0200
parents 2c29d74b11dc
children ede48935f2b3
line diff
     1.1 --- a/view.c	Fri Sep 29 12:56:01 2006 +0200
     1.2 +++ b/view.c	Fri Sep 29 14:39:03 2006 +0200
     1.3 @@ -99,36 +99,39 @@
     1.4  
     1.5  /* This algorithm is based on a (M)aster area and a (S)tacking area.
     1.6   * It supports following arrangements:
     1.7 - * 	MMMS		MMMM		SMMM
     1.8 - * 	MMMS		MMMM		SMMM
     1.9 - * 	MMMS		SSSS		SMMM
    1.10 + * 	SSMMM	MMMMM	MMMSS
    1.11 + * 	SSMMM	SSSSS	MMMSS
    1.12   */
    1.13  void
    1.14  dotile(Arg *arg) {
    1.15 -	int h, i, n, w;
    1.16 +	int i, n, stackw, stackh, tw, th;
    1.17  	Client *c;
    1.18  
    1.19  	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    1.20  		n++;
    1.21  
    1.22 +	if(stackpos == StackBottom) {
    1.23 +		stackw = sw;
    1.24 +		stackh = sh - bh - master;
    1.25 +	}
    1.26 +	else {
    1.27 +		stackw = sw - master;
    1.28 +		stackh = sh - bh;
    1.29 +	}
    1.30 +
    1.31  	if(isvertical) {
    1.32 -		if(stackpos == StackBottom) {
    1.33 -			w = sw;
    1.34 -			if(n > 1)
    1.35 -				h = (sh - bh) / (n - 1);
    1.36 -			else
    1.37 -				h = sh - bh;
    1.38 -		}
    1.39 -		else {
    1.40 -			w = sw - master;
    1.41 -			if(n > 1)
    1.42 -				h = (sh - bh) / (n - 1);
    1.43 -			else
    1.44 -				h = sh - bh;
    1.45 -		}
    1.46 +		tw = stackw;
    1.47 +		if(n > 1)
    1.48 +			th = stackh / (n - 1);
    1.49 +		else
    1.50 +			th = stackh;
    1.51  	}
    1.52 -	else { /* horizontal stack */
    1.53 -
    1.54 +	else {
    1.55 +		th = stackh;
    1.56 +		if(n > 1)
    1.57 +			tw = stackw / (n - 1);
    1.58 +		else
    1.59 +			tw = stackw;
    1.60  	}
    1.61  
    1.62  	for(i = 0, c = clients; c; c = c->next) {
    1.63 @@ -138,32 +141,59 @@
    1.64  				continue;
    1.65  			}
    1.66  			c->ismax = False;
    1.67 -			if(n == 1) {
    1.68 +			if(n == 1) { /* only 1 window */
    1.69  				c->x = sx;
    1.70  				c->y = sy + bh;
    1.71  				c->w = sw - 2 * BORDERPX;
    1.72  				c->h = sh - 2 * BORDERPX - bh;
    1.73  			}
    1.74 -			else if(i == 0) {
    1.75 +			else if(i == 0) { /* master window */
    1.76 +				c->x = sx;
    1.77 +				if(stackpos == StackLeft)
    1.78 +					c->x += master;
    1.79 +				c->y = sy + bh;
    1.80 +				if(isvertical) {
    1.81 +					c->w = master - 2 * BORDERPX;
    1.82 +					c->h = sh - 2 * BORDERPX - bh;
    1.83 +				}
    1.84 +				else {
    1.85 +					c->w = sw;
    1.86 +					c->h = master - 2 * BORDERPX;
    1.87 +				}
    1.88 +			}
    1.89 +			else if((isvertical && th > bh) || (!isvertical && tw > MINW)) {
    1.90 +				/* tile window */
    1.91 +				c->x = sx;
    1.92 +				if(isvertical)
    1.93 +					c->y = sy + (i - 1) * th + bh;
    1.94 +				else
    1.95 +					c->y = sy + bh;
    1.96 +				if(stackpos == StackRight)
    1.97 +					c->x += master;
    1.98 +				else if(stackpos == StackBottom)
    1.99 +					c->y += master;
   1.100 +				c->w = tw - 2 * BORDERPX;
   1.101 +				c->h = th - 2 * BORDERPX;
   1.102 +				if(i + 1 == n) { /* fixes for last tile to take up rest space */
   1.103 +					if(isvertical)
   1.104 +						c->h = sh - c->y - 2 * BORDERPX;
   1.105 +					else {
   1.106 +						if(stackpos == StackLeft)
   1.107 +							c->w = master - c->x - 2 * BORDERPX;
   1.108 +						else
   1.109 +							c->w = sw - c->x - 2 * BORDERPX;
   1.110 +					}
   1.111 +				}
   1.112 +			}
   1.113 +			else { /* fallback if th < bh resp. tw < MINW */
   1.114  				c->x = sx;
   1.115  				c->y = sy + bh;
   1.116 -				c->w = master - 2 * BORDERPX;
   1.117 -				c->h = sh - 2 * BORDERPX - bh;
   1.118 -			}
   1.119 -			else if(h > bh) {
   1.120 -				c->x = sx + master;
   1.121 -				c->y = sy + (i - 1) * h + bh;
   1.122 -				c->w = w - 2 * BORDERPX;
   1.123 -				if(i + 1 == n)
   1.124 -					c->h = sh - c->y - 2 * BORDERPX;
   1.125 -				else
   1.126 -					c->h = h - 2 * BORDERPX;
   1.127 -			}
   1.128 -			else { /* fallback if h < bh */
   1.129 -				c->x = sx + master;
   1.130 -				c->y = sy + bh;
   1.131 -				c->w = w - 2 * BORDERPX;
   1.132 -				c->h = sh - 2 * BORDERPX - bh;
   1.133 +				if(stackpos == StackRight)
   1.134 +					c->x += master;
   1.135 +				else if(stackpos == StackBottom)
   1.136 +					c->y += master;
   1.137 +				c->w = stackw - 2 * BORDERPX;
   1.138 +				c->h = stackh - 2 * BORDERPX;
   1.139  			}
   1.140  			resize(c, False, TopLeft);
   1.141  			i++;
   1.142 @@ -232,12 +262,12 @@
   1.143  		return;
   1.144  
   1.145  	if(sel == getnext(clients)) {
   1.146 -		if(master + arg->i > sw - 100 || master + arg->i < 100)
   1.147 +		if(master + arg->i > sw - MINW || master + arg->i < MINW)
   1.148  			return;
   1.149  		master += arg->i;
   1.150  	}
   1.151  	else {
   1.152 -		if(master - arg->i > sw - 100 || master - arg->i < 100)
   1.153 +		if(master - arg->i > sw - MINW || master - arg->i < MINW)
   1.154  			return;
   1.155  		master -= arg->i;
   1.156  	}