[wiki] [sites] [dwm][patch] new layout support for cfacts patch added || Aaron Duxler
commit 651ca8f15c93158172d0dd187698f6ebbc3b5063
Author: Aaron Duxler <aaron.duxler_AT_gmail.com>
Date: Wed Jun 5 03:27:14 2019 +0200
[dwm][patch] new layout support for cfacts patch added
diff --git a/dwm.suckless.org/patches/cfacts/dwm-cfacts_bottomstack-6.2.diff b/dwm.suckless.org/patches/cfacts/dwm-cfacts_bottomstack-6.2.diff
new file mode 100644
index 00000000..3d045e2f
--- /dev/null
+++ b/dwm.suckless.org/patches/cfacts/dwm-cfacts_bottomstack-6.2.diff
_AT_@ -0,0 +1,139 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2019-06-05 02:24:05.503321320 +0200
++++ b/config.def.h 2019-06-05 02:47:31.106627943 +0200
+_AT_@ -41,6 +41,8 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "TTT", bstack },
++ { "===", bstackhoriz },
+ };
+
+ /* key definitions */
+_AT_@ -79,6 +81,8 @@ static Key keys[] = {
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
++ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+diff -up a/config.def.h.orig b/config.def.h.orig
+--- a/config.def.h.orig 2019-05-30 20:23:02.886614099 +0200
++++ b/config.def.h.orig 2019-06-05 02:26:18.926652113 +0200
+_AT_@ -41,6 +41,8 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "TTT", bstack },
++ { "===", bstackhoriz },
+ };
+
+ /* key definitions */
+_AT_@ -76,6 +78,8 @@ static Key keys[] = {
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
++ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+Only in b: dwm-bottomstack-20160719-56a31dc.diff
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2019-06-05 02:25:40.169986187 +0200
++++ b/dwm.c 2019-06-05 02:50:17.986624775 +0200
+_AT_@ -235,6 +235,8 @@ static int xerror(Display *dpy, XErrorEv
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void bstack(Monitor *m);
++static void bstackhoriz(Monitor *m);
+
+ /* variables */
+ static const char broken[] = "broken";
+_AT_@ -2175,3 +2177,83 @@ main(int argc, char *argv[])
+ XCloseDisplay(dpy);
+ return EXIT_SUCCESS;
+ }
++
++void
++bstack(Monitor *m)
++{
++ unsigned int i, n, w, mh, mx, tx;
++ float mfacts = 0, sfacts = 0;
++ Client *c;
++
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
++ if (n < m->nmaster)
++ mfacts += c->cfact;
++ else
++ sfacts += c->cfact;
++ }
++ if (n == 0)
++ return;
++ if(n == 1){
++ c = nexttiled(m->clients);
++ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
++ return;
++ }
++
++ if (n > m->nmaster)
++ mh = m->nmaster ? m->wh * m->mfact : 0;
++ else
++ mh = m->wh;
++ for (i = 0, mx = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++ if (i < m->nmaster) {
++ w = (m->ww - mx) * (c->cfact / mfacts);
++ resize(c, m->wx + mx, m->wy, w - (2*c->bw), mh - 2*c->bw, 0);
++ mx += WIDTH(c);
++ mfacts -= c->cfact;
++ } else {
++ w = (m->ww - tx) * (c->cfact / sfacts);
++ resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*(c->bw), 0);
++ tx += WIDTH(c);
++ sfacts -= c->cfact;
++ }
++}
++
++void
++bstackhoriz(Monitor *m)
++{
++ unsigned int i, n, h, mw, mh, my, ty;
++ float mfacts = 0, sfacts = 0;
++ Client *c;
++
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
++ if (n < m->nmaster)
++ mfacts += c->cfact;
++ else
++ sfacts += c->cfact;
++ }
++ if (n == 0)
++ return;
++ if(n == 1){
++ c = nexttiled(m->clients);
++ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
++ return;
++ }
++
++ if (n > m->nmaster)
++ mh = m->nmaster ? m->wh * m->mfact : 0;
++ else
++ mh = m->wh;
++ mw = m->ww;
++
++ for (i = ty = 0, my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++ if (i < m->nmaster) {
++ h = (mh - my) * (c->cfact / mfacts);
++ resize(c, m->wx, m->wy + my, mw - 2*c->bw, h - 2*c->bw, 0);
++ my += HEIGHT(c);
++ mfacts -= c->cfact;
++ } else {
++ h = (m->wh - mh - ty) * (c->cfact / sfacts);
++ resize(c, m->wx, m->wy + mh + ty, mw - 2*c->bw, h - (2*c->bw), 0);
++ ty += HEIGHT(c);
++ sfacts -= c->cfact;
++ }
++}
diff --git a/dwm.suckless.org/patches/cfacts/dwm-cfacts_centeredmaster-6.2.diff b/dwm.suckless.org/patches/cfacts/dwm-cfacts_centeredmaster-6.2.diff
new file mode 100644
index 00000000..f645f61a
--- /dev/null
+++ b/dwm.suckless.org/patches/cfacts/dwm-cfacts_centeredmaster-6.2.diff
_AT_@ -0,0 +1,182 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2019-06-05 02:24:05.503321320 +0200
++++ b/config.def.h 2019-06-05 03:06:51.989939224 +0200
+_AT_@ -41,6 +41,8 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "|M|", centeredmaster },
++ { ">M>", centeredfloatingmaster },
+ };
+
+ /* key definitions */
+_AT_@ -79,6 +81,8 @@ static Key keys[] = {
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
++ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+Only in a: config.def.h.orig
+Only in b: dwm-bottomstack-20160719-56a31dc.diff
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2019-06-05 02:25:40.169986187 +0200
++++ b/dwm.c 2019-06-05 03:08:07.379937795 +0200
+_AT_@ -235,6 +235,8 @@ static int xerror(Display *dpy, XErrorEv
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void centeredmaster(Monitor *m);
++static void centeredfloatingmaster(Monitor *m);
+
+ /* variables */
+ static const char broken[] = "broken";
+_AT_@ -2175,3 +2177,146 @@ main(int argc, char *argv[])
+ XCloseDisplay(dpy);
+ return EXIT_SUCCESS;
+ }
++
++void
++centeredmaster(Monitor *m)
++{
++ unsigned int i, n, h, mw, mx, my, oty, ety, tw;
++ float mfacts = 0, lfacts = 0, rfacts = 0;
++ 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 < m->nmaster)
++ mfacts += c->cfact;
++ else if ((n - m->nmaster) % 2)
++ lfacts += c->cfact;
++ else
++ rfacts += c->cfact;
++ }
++ if (n == 0)
++ return;
++ if(n == 1){
++ c = nexttiled(m->clients);
++ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 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 vertically, in the center
++ * of the screen */
++ h = (m->wh - my) * (c->cfact / mfacts);
++ if(m->nmaster >= n)
++ resize(c, m->wx + mx, m->wy + my, mw - 2*c->bw,
++ h - 2*c->bw, 0);
++ else if(m->nmaster + 1 < n)
++ resize(c, m->wx + mx, m->wy + my, mw - 2*(c->bw),
++ h - 2*c->bw, 0);
++ else
++ resize(c, m->wx + mx, m->wy + my, mw - 2*(c->bw),
++ h - 2*c->bw, 0);
++ my += HEIGHT(c);
++ mfacts -= c->cfact;
++ } else {
++ /* stack clients are stacked vertically */
++ if ((i - m->nmaster) % 2) {
++ h = (m->wh - ety) * (c->cfact / (lfacts*2))*2;
++ if(m->nmaster == 0)
++ resize(c, m->wx, m->wy + ety, tw - 2*c->bw,
++ h - 2*c->bw, 0);
++ else
++ resize(c, m->wx, m->wy + ety, tw - 2*c->bw,
++ h - 2*c->bw, 0);
++ ety += HEIGHT(c);
++ lfacts -= c->cfact;
++ } else {
++ h = (m->wh - oty) * (c->cfact / (rfacts*2))*2;
++ resize(c, m->wx + mx + mw, m->wy + oty,
++ tw - 2*c->bw, h - 2*c->bw, 0);
++ oty += HEIGHT(c);
++ rfacts -= c->cfact;
++ }
++ }
++}
++
++void
++centeredfloatingmaster(Monitor *m)
++{
++ unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
++ float mfacts = 0, sfacts = 0;
++ 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 < m->nmaster)
++ mfacts += c->cfact;
++ else
++ sfacts += c->cfact;
++ }
++ if (n == 0)
++ return;
++ if(n == 1){
++ c = nexttiled(m->clients);
++ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 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) * (c->cfact / mfacts);
++ resize(c, m->wx + mx, m->wy + my, w - 2*c->bw,
++ mh - 2*c->bw, 0);
++ mx += WIDTH(c);
++ mfacts -= c->cfact;
++ } else {
++ /* stack clients are stacked horizontally */
++ w = (m->ww - tx) * (c->cfact / sfacts);
++ resize(c, m->wx + tx, m->wy, w - 2*c->bw,
++ m->wh - 2*c->bw, 0);
++ tx += WIDTH(c);
++ sfacts -= c->cfact;
++ }
++}
diff --git a/dwm.suckless.org/patches/cfacts/index.md b/dwm.suckless.org/patches/cfacts/index.md
index d034e253..f4063693 100644
--- a/dwm.suckless.org/patches/cfacts/index.md
+++ b/dwm.suckless.org/patches/cfacts/index.md
_AT_@ -44,6 +44,14 @@ Download
--------
* [dwm-cfacts-6.1.diff](dwm-cfacts-6.1.diff)
+Additional layouts with cfact support
+-------------------------------------
+Just patch these on top of the original cfacts patch.
+
+* [dwm-cfacts\_bottomstack-6.2.diff](dwm-cfacts_bottomstack-6.2.diff)
+* [dwm-cfacts\_centeredmaster-6.2.diff](dwm-cfacts_centeredmaster-6.2.diff)
+
Author
------
* Patrick Steinhardt (pks) <ps_AT_pks.im>
+* Aaron Duxler <aaron.duxler_AT_gmail.com> - Additional layouts bottomstack + centeredmaster
Received on Wed Jun 05 2019 - 03:24:48 CEST
This archive was generated by hypermail 2.3.0
: Wed Jun 05 2019 - 03:36:27 CEST