aewl
diff view.c @ 505:2c29d74b11dc
first step to a more flexible dotile() algorithm
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Fri, 29 Sep 2006 12:38:27 +0200 |
parents | 0cefc169ff67 |
children | 2824b5d0f0f0 |
line diff
1.1 --- a/view.c Thu Sep 28 21:29:20 2006 +0200 1.2 +++ b/view.c Fri Sep 29 12:38:27 2006 +0200 1.3 @@ -65,6 +65,8 @@ 1.4 /* extern */ 1.5 1.6 void (*arrange)(Arg *) = DEFMODE; 1.7 +Bool isvertical = VERTICALSTACK; 1.8 +StackPos stackpos = STACKPOS; 1.9 1.10 void 1.11 detach(Client *c) { 1.12 @@ -97,35 +99,37 @@ 1.13 1.14 /* This algorithm is based on a (M)aster area and a (S)tacking area. 1.15 * It supports following arrangements: 1.16 - * 1.17 - * MMMS MMMM 1.18 - * MMMS MMMM 1.19 - * MMMS SSSS 1.20 - * 1.21 - * The stacking area can be set to arrange clients vertically or horizontally. 1.22 - * Through inverting the algorithm it can be used to achieve following setup in 1.23 - * a dual head environment (due to running two dwm instances concurrently on 1.24 - * the specific screen): 1.25 - * 1.26 - * SMM MMS MMM MMM 1.27 - * SMM MMS MMM MMM 1.28 - * SMM MMS SSS SSS 1.29 - * 1.30 - * This uses the center of the two screens for master areas. 1.31 + * MMMS MMMM SMMM 1.32 + * MMMS MMMM SMMM 1.33 + * MMMS SSSS SMMM 1.34 */ 1.35 void 1.36 dotile(Arg *arg) { 1.37 int h, i, n, w; 1.38 Client *c; 1.39 1.40 - w = sw - mw; 1.41 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 1.42 n++; 1.43 1.44 - if(n > 1) 1.45 - h = (sh - bh) / (n - 1); 1.46 - else 1.47 - h = sh - bh; 1.48 + if(isvertical) { 1.49 + if(stackpos == StackBottom) { 1.50 + w = sw; 1.51 + if(n > 1) 1.52 + h = (sh - bh) / (n - 1); 1.53 + else 1.54 + h = sh - bh; 1.55 + } 1.56 + else { 1.57 + w = sw - master; 1.58 + if(n > 1) 1.59 + h = (sh - bh) / (n - 1); 1.60 + else 1.61 + h = sh - bh; 1.62 + } 1.63 + } 1.64 + else { /* horizontal stack */ 1.65 + 1.66 + } 1.67 1.68 for(i = 0, c = clients; c; c = c->next) { 1.69 if(isvisible(c)) { 1.70 @@ -143,11 +147,11 @@ 1.71 else if(i == 0) { 1.72 c->x = sx; 1.73 c->y = sy + bh; 1.74 - c->w = mw - 2 * BORDERPX; 1.75 + c->w = master - 2 * BORDERPX; 1.76 c->h = sh - 2 * BORDERPX - bh; 1.77 } 1.78 else if(h > bh) { 1.79 - c->x = sx + mw; 1.80 + c->x = sx + master; 1.81 c->y = sy + (i - 1) * h + bh; 1.82 c->w = w - 2 * BORDERPX; 1.83 if(i + 1 == n) 1.84 @@ -156,7 +160,7 @@ 1.85 c->h = h - 2 * BORDERPX; 1.86 } 1.87 else { /* fallback if h < bh */ 1.88 - c->x = sx + mw; 1.89 + c->x = sx + master; 1.90 c->y = sy + bh; 1.91 c->w = w - 2 * BORDERPX; 1.92 c->h = sh - 2 * BORDERPX - bh; 1.93 @@ -228,14 +232,14 @@ 1.94 return; 1.95 1.96 if(sel == getnext(clients)) { 1.97 - if(mw + arg->i > sw - 100 || mw + arg->i < 100) 1.98 + if(master + arg->i > sw - 100 || master + arg->i < 100) 1.99 return; 1.100 - mw += arg->i; 1.101 + master += arg->i; 1.102 } 1.103 else { 1.104 - if(mw - arg->i > sw - 100 || mw - arg->i < 100) 1.105 + if(master - arg->i > sw - 100 || master - arg->i < 100) 1.106 return; 1.107 - mw -= arg->i; 1.108 + master -= arg->i; 1.109 } 1.110 arrange(NULL); 1.111 }