diff options
| author | bakkeby <[email protected]> | 2020-03-20 15:20:07 +0100 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-03-20 15:20:07 +0100 |
| commit | 8047fe257bb95490d5a027a9d3f406f16394108c (patch) | |
| tree | 6904c41307f54373b6c5049903d991ffce77f21e /patch/tile.c | |
| parent | 143f94cbc2d9d6e4a8432677f2af30be70031a9b (diff) | |
| download | dwm-flexipatch-8047fe257bb95490d5a027a9d3f406f16394108c.tar.gz dwm-flexipatch-8047fe257bb95490d5a027a9d3f406f16394108c.zip | |
Layouts - re-distributing remaining pixels after even split to address #12
Diffstat (limited to 'patch/tile.c')
| -rw-r--r-- | patch/tile.c | 122 |
1 files changed, 29 insertions, 93 deletions
diff --git a/patch/tile.c b/patch/tile.c index 3f03483..fa0b90a 100644 --- a/patch/tile.c +++ b/patch/tile.c @@ -1,56 +1,25 @@ -#if VANITYGAPS_PATCH && CFACTS_PATCH static void tile(Monitor *m) { unsigned int i, n; int mx = 0, my = 0, mh = 0, mw = 0; int sx = 0, sy = 0, sh = 0, sw = 0; - int oh, ov, ih, iv; float mfacts, sfacts; + int mrest, srest; Client *c; - getgaps(m, &oh, &ov, &ih, &iv, &n); - getfacts(m, &mfacts, &sfacts); - - if (n == 0) - return; - - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); - sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); - sw = mw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sw = (mw - iv) * (1 - m->mfact); - mw = (mw - iv) * m->mfact; - sx = mx + mw + iv; - } - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - resize(c, mx, my, mw - (2*c->bw), mh * (c->cfact / mfacts) - (2*c->bw), 0); - my += HEIGHT(c) + ih; - } else { - resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0); - sy += HEIGHT(c) + ih; - } -} -#elif VANITYGAPS_PATCH -static void -tile(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; + #if VANITYGAPS_PATCH int oh, ov, ih, iv; - Client *c; - getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH if (n == 0) return; + #if VANITYGAPS_PATCH sx = mx = m->wx + ov; sy = my = m->wy + oh; mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); @@ -62,32 +31,7 @@ tile(Monitor *m) mw = (mw - iv) * m->mfact; sx = mx + mw + iv; } - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - resize(c, mx, my, mw - (2*c->bw), mh / MIN(n, m->nmaster) - (2*c->bw), 0); - my += HEIGHT(c) + ih; - } else { - resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0); - sy += HEIGHT(c) + ih; - } -} -#elif CFACTS_PATCH -static void -tile(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - getfacts(m, &mfacts, &sfacts); - + #else sx = mx = m->wx; sy = my = m->wy; sh = mh = m->wh; @@ -98,40 +42,32 @@ tile(Monitor *m) mw = mw * m->mfact; sx = mx + mw; } + #endif // VANITYGAPS_PATCH + + getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) if (i < m->nmaster) { - resize(c, mx, my, mw - (2*c->bw), mh * (c->cfact / mfacts) - (2*c->bw), 0); + #if CFACTS_PATCH + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + my += HEIGHT(c) + ih; + #else my += HEIGHT(c); + #endif } else { - resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0); + #if CFACTS_PATCH + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sy += HEIGHT(c) + ih; + #else sy += HEIGHT(c); + #endif } -} -#else -void -tile(Monitor *m) -{ - unsigned int i, n, h, mw, my, ty; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - if (n > m->nmaster) - mw = m->nmaster ? m->ww * m->mfact : 0; - else - mw = m->ww; - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - h = (m->wh - my) / (MIN(n, m->nmaster) - i); - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); - my += HEIGHT(c); - } else { - h = (m->wh - ty) / (n - i); - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - ty += HEIGHT(c); - } -} -#endif +}
\ No newline at end of file |
