diff options
Diffstat (limited to 'view.c')
| -rw-r--r-- | view.c | 55 |
1 files changed, 34 insertions, 21 deletions
| @@ -69,12 +69,16 @@ dofloat(void) { | |||
| 69 | 69 | ||
| 70 | void | 70 | void |
| 71 | dotile(void) { | 71 | dotile(void) { |
| 72 | unsigned int i, n, mpw, th; | 72 | unsigned int i, n, mw, mh, tw, th; |
| 73 | Client *c; | 73 | Client *c; |
| 74 | 74 | ||
| 75 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | 75 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
| 76 | n++; | 76 | n++; |
| 77 | mpw = (waw * master) / 1000; | 77 | /* window geoms */ |
| 78 | mw = (n > nmaster) ? (waw * master) / 1000 : waw; | ||
| 79 | mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); | ||
| 80 | tw = waw - mw; | ||
| 81 | th = (n > nmaster) ? wah / (n - nmaster) : 0; | ||
| 78 | 82 | ||
| 79 | for(i = 0, c = clients; c; c = c->next) | 83 | for(i = 0, c = clients; c; c = c->next) |
| 80 | if(isvisible(c)) { | 84 | if(isvisible(c)) { |
| @@ -85,20 +89,16 @@ dotile(void) { | |||
| 85 | c->ismax = False; | 89 | c->ismax = False; |
| 86 | c->x = wax; | 90 | c->x = wax; |
| 87 | c->y = way; | 91 | c->y = way; |
| 88 | if(n == 1) { /* only 1 window */ | 92 | if(i < nmaster) { |
| 89 | c->w = waw - 2 * BORDERPX; | 93 | c->y += i * mh; |
| 90 | c->h = wah - 2 * BORDERPX; | 94 | c->w = mw - 2 * BORDERPX; |
| 91 | } | 95 | c->h = mh - 2 * BORDERPX; |
| 92 | else if(i == 0) { /* master window */ | ||
| 93 | c->w = mpw - 2 * BORDERPX; | ||
| 94 | c->h = wah - 2 * BORDERPX; | ||
| 95 | th = wah / (n - 1); | ||
| 96 | } | 96 | } |
| 97 | else { /* tile window */ | 97 | else { /* tile window */ |
| 98 | c->x += mpw; | 98 | c->x += mw; |
| 99 | c->w = (waw - mpw) - 2 * BORDERPX; | 99 | c->w = tw - 2 * BORDERPX; |
| 100 | if(th > bh) { | 100 | if(th > bh) { |
| 101 | c->y += (i - 1) * th; | 101 | c->y += (i - nmaster) * th; |
| 102 | c->h = th - 2 * BORDERPX; | 102 | c->h = th - 2 * BORDERPX; |
| 103 | } | 103 | } |
| 104 | else /* fallback if th < bh */ | 104 | else /* fallback if th < bh */ |
| @@ -147,6 +147,14 @@ focusprev(Arg *arg) { | |||
| 147 | } | 147 | } |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | void | ||
| 151 | incnmaster(Arg *arg) { | ||
| 152 | if(nmaster + arg->i < 1) | ||
| 153 | return; | ||
| 154 | nmaster += arg->i; | ||
| 155 | arrange(); | ||
| 156 | } | ||
| 157 | |||
| 150 | Bool | 158 | Bool |
| 151 | isvisible(Client *c) { | 159 | isvisible(Client *c) { |
| 152 | unsigned int i; | 160 | unsigned int i; |
| @@ -240,7 +248,7 @@ view(Arg *arg) { | |||
| 240 | 248 | ||
| 241 | void | 249 | void |
| 242 | zoom(Arg *arg) { | 250 | zoom(Arg *arg) { |
| 243 | unsigned int n; | 251 | unsigned int i, n; |
| 244 | Client *c; | 252 | Client *c; |
| 245 | 253 | ||
| 246 | if(!sel) | 254 | if(!sel) |
| @@ -249,14 +257,19 @@ zoom(Arg *arg) { | |||
| 249 | togglemax(sel); | 257 | togglemax(sel); |
| 250 | return; | 258 | return; |
| 251 | } | 259 | } |
| 252 | for(n = 0, c = clients; c; c = c->next) | 260 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
| 253 | if(isvisible(c) && !c->isfloat) | 261 | n++; |
| 254 | n++; | 262 | if(n <= nmaster || (arrange == dofloat)) |
| 255 | if(n < 2 || (arrange == dofloat)) | ||
| 256 | return; | 263 | return; |
| 257 | if((c = sel) == nexttiled(clients)) | 264 | |
| 258 | if(!(c = nexttiled(c->next))) | 265 | for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next)) |
| 259 | return; | 266 | i++; |
| 267 | if(c == sel && i < nmaster) | ||
| 268 | for(; c && i < nmaster; c = nexttiled(c->next)) | ||
| 269 | i++; | ||
| 270 | if(!c) | ||
| 271 | return; | ||
| 272 | |||
| 260 | detach(c); | 273 | detach(c); |
| 261 | if(clients) | 274 | if(clients) |
| 262 | clients->prev = c; | 275 | clients->prev = c; |
