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/centeredfloatingmaster.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/centeredfloatingmaster.c')
| -rw-r--r-- | patch/centeredfloatingmaster.c | 180 |
1 files changed, 36 insertions, 144 deletions
diff --git a/patch/centeredfloatingmaster.c b/patch/centeredfloatingmaster.c index d4fcb5d..e052c24 100644 --- a/patch/centeredfloatingmaster.c +++ b/patch/centeredfloatingmaster.c @@ -1,83 +1,33 @@ -#if VANITYGAPS_PATCH && CFACTS_PATCH void centeredfloatingmaster(Monitor *m) { unsigned int i, n; - float mivf, mfacts, sfacts; + float mfacts, sfacts; + int mrest, srest; int mx = 0, my = 0, mh = 0, mw = 0; int sx = 0, sy = 0, sh = 0, sw = 0; - int oh, ov, ih, iv; Client *c; - getgaps(m, &oh, &ov, &ih, &iv, &n); - getfacts(m, &mfacts, &sfacts); - - if (n == 0) - return; - - mivf = 0.8; // master inner vertical gap factor - - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh; - sw = mw = m->ww - 2*ov - iv*(n - 1); - - if (m->nmaster && n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (m->ww > m->wh) { - mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); - mh = m->wh * 0.9; - } else { - mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1); - mh = m->wh * m->mfact; - } - mx = m->wx + (m->ww - mw) / 2; - my = m->wy + (m->wh - mh - 2*oh) / 2; - - sx = m->wx + ov; - sy = m->wy + oh; - sh = m->wh - 2*oh; - sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); - } - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i < m->nmaster) { - /* nmaster clients are stacked horizontally, in the center of the screen */ - resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0); - mx += WIDTH(c) + iv*mivf; - focus(c); - } else { - /* stack clients are stacked horizontally */ - resize(c, sx, sy, sw * (c->cfact / sfacts) - (2*c->bw), sh - (2*c->bw), 0); - sx += WIDTH(c) + iv; - } - } - restack(m); -} -#elif VANITYGAPS_PATCH -void -centeredfloatingmaster(Monitor *m) -{ - unsigned int i, n; - float mivf; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; + #if VANITYGAPS_PATCH + float mivf = 1.0; // master inner vertical gap factor 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; - mivf = 0.8; // master inner vertical gap factor - + #if VANITYGAPS_PATCH sx = mx = m->wx + ov; sy = my = m->wy + oh; sh = mh = m->wh - 2*oh; - sw = mw = m->ww - 2*ov - iv*(n - 1); + mw = m->ww - 2*ov - iv*(n - 1); + sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); if (m->nmaster && n > m->nmaster) { + mivf = 0.8; /* go mfact box in the center if more than nmaster clients */ if (m->ww > m->wh) { mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); @@ -92,39 +42,8 @@ centeredfloatingmaster(Monitor *m) sx = m->wx + ov; sy = m->wy + oh; sh = m->wh - 2*oh; - sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); - } - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i < m->nmaster) { - /* nmaster clients are stacked horizontally, in the center of the screen */ - resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0); - mx += WIDTH(c) + iv*mivf; - focus(c); - } else { - /* stack clients are stacked horizontally */ - resize(c, sx, sy, sw / (n - MIN(n, m->nmaster)) - (2*c->bw), sh - (2*c->bw), 0); - sx += WIDTH(c) + iv; - } } - restack(m); -} -#elif CFACTS_PATCH -void -centeredfloatingmaster(Monitor *m) -{ - unsigned int i, n; - float mfacts, sfacts; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - 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; @@ -142,64 +61,37 @@ centeredfloatingmaster(Monitor *m) mx = m->wx + (m->ww - mw) / 2; my = m->wy + (m->wh - mh) / 2; } + #endif // VANITYGAPS_PATCH - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i < m->nmaster) { - /* nmaster clients are stacked horizontally, in the center of the screen */ - resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0); - mx += WIDTH(c); - focus(c); - } else { - /* stack clients are stacked horizontally */ - resize(c, sx, sy, sw * (c->cfact / sfacts) - (2*c->bw), sh - (2*c->bw), 0); - sx += WIDTH(c); - } - } - restack(m); -} -#else -void -centeredfloatingmaster(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (m->ww > m->wh) { - mw = m->ww * m->mfact; - mh = m->wh * 0.9; - } else { - mw = m->ww * 0.9; - mh = m->wh * m->mfact; - } - mx = m->wx + (m->ww - mw) / 2; - my = m->wy + (m->wh - mh) / 2; - } + getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) if (i < m->nmaster) { /* nmaster clients are stacked horizontally, in the center of the screen */ - resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0); + #if CFACTS_PATCH + resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #else + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + mx += WIDTH(c) + iv*mivf; + #else mx += WIDTH(c); - focus(c); + #endif + detachstack(c); + attachstack(c); } else { /* stack clients are stacked horizontally */ - resize(c, sx, sy, sw / (n - MIN(n, m->nmaster)) - (2*c->bw), sh - (2*c->bw), 0); + #if CFACTS_PATCH + resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #else + resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sx += WIDTH(c) + iv; + #else sx += WIDTH(c); + #endif } - } restack(m); -} -#endif
\ No newline at end of file +}
\ No newline at end of file |
