X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=view.c;h=503f1c2ba46377e2fad3b60d2332b0c5fc320ad4;hb=e9cfae7aba1c8eafd827854705bf0d11d2de2dfb;hp=b3b412d8ea421b0fb6099caaba4dcdf63c60d0ec;hpb=cb4aa5bc35cf16a06bb2b4e880648e390fa2cc55;p=dwm.git diff --git a/view.c b/view.c index b3b412d..503f1c2 100644 --- a/view.c +++ b/view.c @@ -1,4 +1,4 @@ -/* (C)opyright MMVII Anselm R. Garbe +/* (C)opyright MMVI-MMVII Anselm R. Garbe * See LICENSE file for license details. */ #include "dwm.h" @@ -69,12 +69,16 @@ dofloat(void) { void dotile(void) { - unsigned int i, n, mpw, th; + unsigned int i, n, mw, mh, tw, th; Client *c; for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) n++; - mpw = (waw * master) / 1000; + /* window geoms */ + mw = (n > nmaster) ? (waw * master) / 1000 : waw; + mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); + tw = waw - mw; + th = (n > nmaster) ? wah / (n - nmaster) : 0; for(i = 0, c = clients; c; c = c->next) if(isvisible(c)) { @@ -85,20 +89,16 @@ dotile(void) { c->ismax = False; c->x = wax; c->y = way; - if(n == 1) { /* only 1 window */ - c->w = waw - 2 * BORDERPX; - c->h = wah - 2 * BORDERPX; - } - else if(i == 0) { /* master window */ - c->w = mpw - 2 * BORDERPX; - c->h = wah - 2 * BORDERPX; - th = wah / (n - 1); + if(i < nmaster) { + c->y += i * mh; + c->w = mw - 2 * BORDERPX; + c->h = mh - 2 * BORDERPX; } else { /* tile window */ - c->x += mpw; - c->w = (waw - mpw) - 2 * BORDERPX; + c->x += mw; + c->w = tw - 2 * BORDERPX; if(th > bh) { - c->y += (i - 1) * th; + c->y += (i - nmaster) * th; c->h = th - 2 * BORDERPX; } else /* fallback if th < bh */ @@ -147,6 +147,14 @@ focusprev(Arg *arg) { } } +void +incnmaster(Arg *arg) { + if((nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh)) + return; + nmaster += arg->i; + arrange(); +} + Bool isvisible(Client *c) { unsigned int i; @@ -249,19 +257,17 @@ zoom(Arg *arg) { togglemax(sel); return; } - for(n = 0, c = clients; c; c = c->next) - if(isvisible(c) && !c->isfloat) - n++; - if(n < 2 || (arrange == dofloat)) - return; - if((c = sel) == nexttiled(clients)) - if(!(c = nexttiled(c->next))) - return; - detach(c); - if(clients) - clients->prev = c; - c->next = clients; - clients = c; - focus(c); - arrange(); + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) + n++; + + c = sel; + if((arrange != dofloat) && c != nexttiled(clients)) { + detach(c); + if(clients) + clients->prev = c; + c->next = clients; + clients = c; + focus(c); + arrange(); + } }