[wiki] [sites] Add `centedermaster` layout patch || jeromenerf

From: <git_AT_suckless.org>
Date: Sun, 16 Aug 2015 18:32:38 +0200

commit c35a177bfa9cb58306352c3f6e83e286ea17d8fe
Author: jeromenerf <jerome.andrieux_AT_gmail.com>
Date: Sun Aug 16 18:31:12 2015 +0200

    Add `centedermaster` layout patch
    
    - nmaster area is displayed in the center of the screen
    - stack is displayed below in an horizontally tiled layout, similar to
      `htile`
    - page and patch attached

diff --git a/dwm.suckless.org/patches/centeredmaster.md b/dwm.suckless.org/patches/centeredmaster.md
new file mode 100644
index 0000000..e48a651
--- /dev/null
+++ b/dwm.suckless.org/patches/centeredmaster.md
_AT_@ -0,0 +1,63 @@
+# 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".
+
+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, ...).
+
+
+
+```
+With one client in master:
++------------------------------+
+|+--------++--------++--------+|
+|| || || ||
+|| +------------------+ ||
+|| | | ||
+|| | | ||
+|| | M | ||
+|| | | ||
+|| +------------------+ ||
+|| || || ||
+|+--------++--------++--------+|
++------------------------------+
+
+With two clients in master:
++------------------------------+
+|+--------++--------++--------+|
+|| || || ||
+|| +--------++--------+ ||
+|| | || | ||
+|| | || | ||
+|| | M1 || M2 | ||
+|| | || | ||
+|| +--------++--------+ ||
+|| || || ||
+|+--------++--------++--------+|
++------------------------------+
+```
+
+## Links
+
+* [dwm-6.1-centeredmaster.diff](dwm-6.1-centeredmaster.diff) - 4K, 2015/08/15
+
+
+[http://blog.jardinmagique.info](jerome) <jerome_AT_gcu.info>
+
+
+
+
+
+
+
+
+
+
diff --git a/dwm.suckless.org/patches/dwm-6.1-centeredmaster.diff b/dwm.suckless.org/patches/dwm-6.1-centeredmaster.diff
new file mode 100644
index 0000000..a6a013c
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-6.1-centeredmaster.diff
_AT_@ -0,0 +1,58 @@
+diff --git a/dwm.c b/dwm.c
+index 783fcdb..ab179d8 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -215,6 +215,7 @@ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void htile(Monitor *);
++static void centeredmaster(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+_AT_@ -1748,6 +1749,45 @@ htile(Monitor *m) {
+ }
+
+ void
++centeredmaster(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
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ mh = m->nmaster ? m->wh * m->mfact : 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 = mxo = 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, tx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
++ tx += WIDTH(c);
++ }
++}
++
++void
+ togglebar(const Arg *arg) {
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
+ updatebarpos(selmon);
Received on Sun Aug 16 2015 - 18:32:38 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 16 2015 - 18:36:10 CEST