dwm-meillo

diff view.c @ 508:ede48935f2b3

added the new dotile as described on ml
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 29 Sep 2006 16:22:20 +0200
parents 2824b5d0f0f0
children 0dfa6b752aed
line diff
     1.1 --- a/view.c	Fri Sep 29 14:39:03 2006 +0200
     1.2 +++ b/view.c	Fri Sep 29 16:22:20 2006 +0200
     1.3 @@ -148,52 +148,93 @@
     1.4  				c->h = sh - 2 * BORDERPX - bh;
     1.5  			}
     1.6  			else if(i == 0) { /* master window */
     1.7 -				c->x = sx;
     1.8 -				if(stackpos == StackLeft)
     1.9 -					c->x += master;
    1.10 -				c->y = sy + bh;
    1.11 -				if(isvertical) {
    1.12 +				switch(stackpos) {
    1.13 +				case StackLeft:
    1.14 +					c->x = sx + stackw;
    1.15 +					c->y = sy + bh;
    1.16  					c->w = master - 2 * BORDERPX;
    1.17 -					c->h = sh - 2 * BORDERPX - bh;
    1.18 -				}
    1.19 -				else {
    1.20 -					c->w = sw;
    1.21 +					c->h = sh - bh - 2 * BORDERPX;
    1.22 +					break;
    1.23 +				case StackBottom:
    1.24 +					c->x = sx;
    1.25 +					c->y = sy + bh;
    1.26 +					c->w = sw - 2 * BORDERPX;
    1.27  					c->h = master - 2 * BORDERPX;
    1.28 +					break;
    1.29 +				case StackRight:
    1.30 +					c->x = sx;
    1.31 +					c->y = sy + bh;
    1.32 +					c->w = master - 2 * BORDERPX;
    1.33 +					c->h = sh - bh - 2 * BORDERPX;
    1.34 +					break;
    1.35  				}
    1.36  			}
    1.37  			else if((isvertical && th > bh) || (!isvertical && tw > MINW)) {
    1.38  				/* tile window */
    1.39 -				c->x = sx;
    1.40 -				if(isvertical)
    1.41 -					c->y = sy + (i - 1) * th + bh;
    1.42 -				else
    1.43 -					c->y = sy + bh;
    1.44 -				if(stackpos == StackRight)
    1.45 -					c->x += master;
    1.46 -				else if(stackpos == StackBottom)
    1.47 -					c->y += master;
    1.48  				c->w = tw - 2 * BORDERPX;
    1.49  				c->h = th - 2 * BORDERPX;
    1.50 -				if(i + 1 == n) { /* fixes for last tile to take up rest space */
    1.51 -					if(isvertical)
    1.52 -						c->h = sh - c->y - 2 * BORDERPX;
    1.53 +				switch(stackpos) {
    1.54 +				case StackLeft:
    1.55 +					if(isvertical) {
    1.56 +						c->x = sx;
    1.57 +						c->y = sy + (i - 1) * th + bh;
    1.58 +						if(i + 1 == n)
    1.59 +							c->h = sh - c->y - 2 * BORDERPX;
    1.60 +					}
    1.61  					else {
    1.62 -						if(stackpos == StackLeft)
    1.63 -							c->w = master - c->x - 2 * BORDERPX;
    1.64 -						else
    1.65 +						c->x = sx + (i - 1) * tw;
    1.66 +						c->y = sy + bh;
    1.67 +						if(i + 1 == n)
    1.68 +							c->w = sx + stackw - c->x - 2 * BORDERPX;
    1.69 +					}
    1.70 +					break;
    1.71 +				case StackBottom:
    1.72 +					if(isvertical) {
    1.73 +						c->x = sx;
    1.74 +						c->y = sy + master + (i - 1) * th + bh;
    1.75 +						if(i + 1 == n)
    1.76 +							c->h = sh - c->y - 2 * BORDERPX;
    1.77 +					}
    1.78 +					else {
    1.79 +						c->x = sx + (i - 1) * tw;
    1.80 +						c->y = sy + bh + master;
    1.81 +						if(i + 1 == n)
    1.82  							c->w = sw - c->x - 2 * BORDERPX;
    1.83  					}
    1.84 +					break;
    1.85 +				case StackRight:
    1.86 +					if(isvertical) {
    1.87 +						c->x = sx + master;
    1.88 +						c->y = sy + (i - 1) * th + bh;
    1.89 +						if(i + 1 == n)
    1.90 +							c->h = sh - c->y - 2 * BORDERPX;
    1.91 +					}
    1.92 +					else {
    1.93 +						c->x = sx + master + (i - 1) * tw;
    1.94 +						c->y = sy + bh;
    1.95 +						if(i + 1 == n)
    1.96 +							c->w = sx + stackw - c->x - 2 * BORDERPX;
    1.97 +					}
    1.98 +					break;
    1.99  				}
   1.100  			}
   1.101  			else { /* fallback if th < bh resp. tw < MINW */
   1.102 -				c->x = sx;
   1.103 -				c->y = sy + bh;
   1.104 -				if(stackpos == StackRight)
   1.105 -					c->x += master;
   1.106 -				else if(stackpos == StackBottom)
   1.107 -					c->y += master;
   1.108  				c->w = stackw - 2 * BORDERPX;
   1.109  				c->h = stackh - 2 * BORDERPX;
   1.110 +				switch(stackpos) {
   1.111 +				case StackLeft:
   1.112 +					c->x = sx;
   1.113 +					c->y = sy + bh;
   1.114 +					break;
   1.115 +				case StackBottom:
   1.116 +					c->x = sx;
   1.117 +					c->y = sy + master;
   1.118 +					break;
   1.119 +				case StackRight:
   1.120 +					c->x = sx + master;
   1.121 +					c->y = sy + bh;
   1.122 +					break;
   1.123 +				}
   1.124  			}
   1.125  			resize(c, False, TopLeft);
   1.126  			i++;
   1.127 @@ -319,6 +360,31 @@
   1.128  }
   1.129  
   1.130  void
   1.131 +togglestackdir(Arg *arg) {
   1.132 +	if(arrange == dofloat)
   1.133 +		return;
   1.134 +	isvertical = !isvertical;
   1.135 +	arrange(NULL);
   1.136 +}
   1.137 +
   1.138 +void
   1.139 +togglestackpos(Arg *arg) {
   1.140 +	if(arrange == dofloat)
   1.141 +		return;
   1.142 +	if(stackpos == StackBottom)
   1.143 +		stackpos = STACKPOS;
   1.144 +	else
   1.145 +		stackpos = StackBottom;
   1.146 +	updatemaster();
   1.147 +	arrange(NULL);
   1.148 +}
   1.149 +
   1.150 +void
   1.151 +updatemaster(void) {
   1.152 +	master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
   1.153 +}
   1.154 +
   1.155 +void
   1.156  view(Arg *arg) {
   1.157  	unsigned int i;
   1.158  
   1.159 @@ -339,6 +405,8 @@
   1.160  	arrange(NULL);
   1.161  }
   1.162  
   1.163 +
   1.164 +
   1.165  void
   1.166  zoom(Arg *arg) {
   1.167  	unsigned int n;