sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 8785a283200fc4e0434e1e2735038df85734a983
parent 308ff4d29063492a2386fe52c56a076aa5075298
Author: jeromenerf <jerome.andrieux@af83.com>
Date:   Sun, 22 Nov 2015 23:08:47 +0100

Update centered master patch

Diffstat:
Adwm.suckless.org/patches/centeredmaster.c | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdwm.suckless.org/patches/centeredmaster.md | 60++++++++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 141 insertions(+), 10 deletions(-)

diff --git a/dwm.suckless.org/patches/centeredmaster.c b/dwm.suckless.org/patches/centeredmaster.c @@ -0,0 +1,91 @@ +void +centeredfloatingmaster(Monitor *m) { + unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx; + Client *c; + + // Count number of clients in the selected monitor + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + // initialize nmaster area + if(n > m->nmaster) { + // go mfact box in the center if more than nmaster clients + if(m->ww > m->wh) { + mw = m->nmaster ? m->ww * m->mfact : 0; + mh = m->nmaster ? m->wh * 0.9 : 0; + } else { + mh = m->nmaster ? m->wh * m->mfact : 0; + mw = m->nmaster ? m->ww * 0.9 : 0; + } + mx = mxo = (m->ww - mw) / 2; + my = myo = (m->wh - mh) / 2; + } else { + // Go fullscreen if all clients are in the master area + mh = m->wh; + mw = m->ww; + mx = mxo = 0; + my = myo = 0; + } + for(i = tx = 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 + w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy + my, w - (2*c->bw), mh - (2*c->bw), False); + mx += WIDTH(c); + } else { + // Stack clients are stacked horizontally + w = (m->ww - tx) / (n - i); + resize(c, m->wx + tx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False); + tx += WIDTH(c); + } +} + +void +centeredmaster(Monitor *m) { + unsigned int i, n, h, mw, mx, my, oty, ety, tw; + Client *c; + + // Count number of clients in the selected monitor + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + // initialize areas + mw = m->ww; + mx = 0; + my = 0; + tw = mw; + + if(n > m->nmaster) { + // go mfact box in the center if more than nmaster clients + mw = m->nmaster ? m->ww * m->mfact : 0; + tw = m->ww - mw; + + if (n - m->nmaster > 1) { // only one client + mx = (m->ww - mw) / 2; + tw = (m->ww - mw) / 2; + } + } + + oty = 0; + ety = 0; + for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if(i < m->nmaster) { + // nmaster clients are stacked verticaly, in the center of the screen + h = (m->wh - my) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False); + my += HEIGHT(c); + } else { + // Stack clients are stacked verticaly + if ((i - m->nmaster) % 2 ) { + h = (m->wh - ety) / ( (1 + n - i) / 2); + resize(c, m->wx, m->wy + ety, tw - (2*c->bw), h - (2*c->bw), False); + ety += HEIGHT(c); + } else { + h = (m->wh - oty) / ((1 + n - i) / 2); + resize(c, m->wx + mx + mw, m->wy + oty, tw - (2*c->bw), h - (2*c->bw), False); + oty += HEIGHT(c); + } + } +} diff --git a/dwm.suckless.org/patches/centeredmaster.md b/dwm.suckless.org/patches/centeredmaster.md @@ -1,19 +1,47 @@ # centeredmaster -`centeredmaster` layout patch makes the nmaster area centered -on screen, using `mfact * monitor width & height`, over an -horizontally tiled `stack` area, pretty much like -a "scratchpad". +## `centeredmaster` -I find it useful on large screens (say 1920px wide), where -`monocle` or `htile` feels either too large or makes me type in -a corner of the screen. +makes the nmaster area centered +on screen, using `mfact * monitor width & height`, with the stacked windows +distributed on left and right. -With `centeredmaster`, for instance, I can set my editor in the -center, while keeping an eye on what's happening in the windows -behind (logs, tests, ...). +With one client in master: + +------------------------------+ + |+--------++--------++--------+| + || || || || + || || || || + || || || || + || S2 || M || S1 || + || || || || + || || || || + || || || || + || || || || + |+--------++--------++--------+| + +------------------------------+ +With two clients in master: + + +------------------------------+ + |+--------++--------++--------+| + || || || || + || || M1 || || + || || || || + || |+--------+| || + || |+--------+| || + || || || || + || || M2 || || + || || || || + |+--------++--------++--------+| + +------------------------------+ + +## `centeredfloatingmaster` + +makes the nmaster area centered +on screen, using `mfact * monitor width & height`, over an +horizontally tiled `stack` area, pretty much like +a "scratchpad". With one client in master: @@ -46,8 +74,20 @@ With two clients in master: +------------------------------+ +I find it useful on large screens (say 1920px wide), where +`monocle` or `htile` feels either too large or makes me type in +a corner of the screen. + +With `centeredmaster`, for instance, I can set my editor in the +center, while keeping an eye on what's happening in the windows +behind (logs, tests, ...). + + + + ## Links +* [centeredmaster.c](centeredmaster.c) - 2015/11/22 * [dwm-6.1-centeredmaster.diff](dwm-6.1-centeredmaster.diff) - 2015/11/21