aewl
changeset 507:2824b5d0f0f0
prelim of dotile()
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Fri, 29 Sep 2006 14:39:03 +0200 |
parents | b467b5a749db |
children | ede48935f2b3 |
files | dwm.h view.c |
diffstat | 2 files changed, 72 insertions(+), 41 deletions(-) [+] |
line diff
1.1 --- a/dwm.h Fri Sep 29 12:56:01 2006 +0200 1.2 +++ b/dwm.h Fri Sep 29 14:39:03 2006 +0200 1.3 @@ -40,6 +40,7 @@ 1.4 #define MOUSEMASK (BUTTONMASK | PointerMotionMask) 1.5 /* other stuff used in different places */ 1.6 #define BORDERPX 1 1.7 +#define MINW 100 1.8 #define PROTODELWIN 1 1.9 1.10 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
2.1 --- a/view.c Fri Sep 29 12:56:01 2006 +0200 2.2 +++ b/view.c Fri Sep 29 14:39:03 2006 +0200 2.3 @@ -99,36 +99,39 @@ 2.4 2.5 /* This algorithm is based on a (M)aster area and a (S)tacking area. 2.6 * It supports following arrangements: 2.7 - * MMMS MMMM SMMM 2.8 - * MMMS MMMM SMMM 2.9 - * MMMS SSSS SMMM 2.10 + * SSMMM MMMMM MMMSS 2.11 + * SSMMM SSSSS MMMSS 2.12 */ 2.13 void 2.14 dotile(Arg *arg) { 2.15 - int h, i, n, w; 2.16 + int i, n, stackw, stackh, tw, th; 2.17 Client *c; 2.18 2.19 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 2.20 n++; 2.21 2.22 + if(stackpos == StackBottom) { 2.23 + stackw = sw; 2.24 + stackh = sh - bh - master; 2.25 + } 2.26 + else { 2.27 + stackw = sw - master; 2.28 + stackh = sh - bh; 2.29 + } 2.30 + 2.31 if(isvertical) { 2.32 - if(stackpos == StackBottom) { 2.33 - w = sw; 2.34 - if(n > 1) 2.35 - h = (sh - bh) / (n - 1); 2.36 - else 2.37 - h = sh - bh; 2.38 - } 2.39 - else { 2.40 - w = sw - master; 2.41 - if(n > 1) 2.42 - h = (sh - bh) / (n - 1); 2.43 - else 2.44 - h = sh - bh; 2.45 - } 2.46 + tw = stackw; 2.47 + if(n > 1) 2.48 + th = stackh / (n - 1); 2.49 + else 2.50 + th = stackh; 2.51 } 2.52 - else { /* horizontal stack */ 2.53 - 2.54 + else { 2.55 + th = stackh; 2.56 + if(n > 1) 2.57 + tw = stackw / (n - 1); 2.58 + else 2.59 + tw = stackw; 2.60 } 2.61 2.62 for(i = 0, c = clients; c; c = c->next) { 2.63 @@ -138,32 +141,59 @@ 2.64 continue; 2.65 } 2.66 c->ismax = False; 2.67 - if(n == 1) { 2.68 + if(n == 1) { /* only 1 window */ 2.69 c->x = sx; 2.70 c->y = sy + bh; 2.71 c->w = sw - 2 * BORDERPX; 2.72 c->h = sh - 2 * BORDERPX - bh; 2.73 } 2.74 - else if(i == 0) { 2.75 + else if(i == 0) { /* master window */ 2.76 + c->x = sx; 2.77 + if(stackpos == StackLeft) 2.78 + c->x += master; 2.79 + c->y = sy + bh; 2.80 + if(isvertical) { 2.81 + c->w = master - 2 * BORDERPX; 2.82 + c->h = sh - 2 * BORDERPX - bh; 2.83 + } 2.84 + else { 2.85 + c->w = sw; 2.86 + c->h = master - 2 * BORDERPX; 2.87 + } 2.88 + } 2.89 + else if((isvertical && th > bh) || (!isvertical && tw > MINW)) { 2.90 + /* tile window */ 2.91 + c->x = sx; 2.92 + if(isvertical) 2.93 + c->y = sy + (i - 1) * th + bh; 2.94 + else 2.95 + c->y = sy + bh; 2.96 + if(stackpos == StackRight) 2.97 + c->x += master; 2.98 + else if(stackpos == StackBottom) 2.99 + c->y += master; 2.100 + c->w = tw - 2 * BORDERPX; 2.101 + c->h = th - 2 * BORDERPX; 2.102 + if(i + 1 == n) { /* fixes for last tile to take up rest space */ 2.103 + if(isvertical) 2.104 + c->h = sh - c->y - 2 * BORDERPX; 2.105 + else { 2.106 + if(stackpos == StackLeft) 2.107 + c->w = master - c->x - 2 * BORDERPX; 2.108 + else 2.109 + c->w = sw - c->x - 2 * BORDERPX; 2.110 + } 2.111 + } 2.112 + } 2.113 + else { /* fallback if th < bh resp. tw < MINW */ 2.114 c->x = sx; 2.115 c->y = sy + bh; 2.116 - c->w = master - 2 * BORDERPX; 2.117 - c->h = sh - 2 * BORDERPX - bh; 2.118 - } 2.119 - else if(h > bh) { 2.120 - c->x = sx + master; 2.121 - c->y = sy + (i - 1) * h + bh; 2.122 - c->w = w - 2 * BORDERPX; 2.123 - if(i + 1 == n) 2.124 - c->h = sh - c->y - 2 * BORDERPX; 2.125 - else 2.126 - c->h = h - 2 * BORDERPX; 2.127 - } 2.128 - else { /* fallback if h < bh */ 2.129 - c->x = sx + master; 2.130 - c->y = sy + bh; 2.131 - c->w = w - 2 * BORDERPX; 2.132 - c->h = sh - 2 * BORDERPX - bh; 2.133 + if(stackpos == StackRight) 2.134 + c->x += master; 2.135 + else if(stackpos == StackBottom) 2.136 + c->y += master; 2.137 + c->w = stackw - 2 * BORDERPX; 2.138 + c->h = stackh - 2 * BORDERPX; 2.139 } 2.140 resize(c, False, TopLeft); 2.141 i++; 2.142 @@ -232,12 +262,12 @@ 2.143 return; 2.144 2.145 if(sel == getnext(clients)) { 2.146 - if(master + arg->i > sw - 100 || master + arg->i < 100) 2.147 + if(master + arg->i > sw - MINW || master + arg->i < MINW) 2.148 return; 2.149 master += arg->i; 2.150 } 2.151 else { 2.152 - if(master - arg->i > sw - 100 || master - arg->i < 100) 2.153 + if(master - arg->i > sw - MINW || master - arg->i < MINW) 2.154 return; 2.155 master -= arg->i; 2.156 }