dwm-cfacts_bottomstack-6.2.diff (3863B)
1 diff -up a/config.def.h b/config.def.h 2 --- a/config.def.h 2019-06-06 21:23:27.006661784 +0200 3 +++ b/config.def.h 2019-06-06 21:31:38.133319129 +0200 4 @@ -41,6 +41,8 @@ static const Layout layouts[] = { 5 { "[]=", tile }, /* first entry is default */ 6 { "><>", NULL }, /* no layout function means floating behavior */ 7 { "[M]", monocle }, 8 + { "TTT", bstack }, 9 + { "===", bstackhoriz }, 10 }; 11 12 /* key definitions */ 13 @@ -79,6 +81,8 @@ static Key keys[] = { 14 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 15 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 16 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 17 + { MODKEY, XK_u, setlayout, {.v = &layouts[3]} }, 18 + { MODKEY, XK_o, setlayout, {.v = &layouts[4]} }, 19 { MODKEY, XK_space, setlayout, {0} }, 20 { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 21 { MODKEY, XK_0, view, {.ui = ~0 } }, 22 Only in a: config.def.h.orig 23 Only in b: config.def.h.orig.orig 24 Only in b: dwm-bottomstack-20160719-56a31dc.diff 25 diff -up a/dwm.c b/dwm.c 26 --- a/dwm.c 2019-06-06 21:23:27.023328450 +0200 27 +++ b/dwm.c 2019-06-06 21:31:38.133319129 +0200 28 @@ -235,6 +235,8 @@ static int xerror(Display *dpy, XErrorEv 29 static int xerrordummy(Display *dpy, XErrorEvent *ee); 30 static int xerrorstart(Display *dpy, XErrorEvent *ee); 31 static void zoom(const Arg *arg); 32 +static void bstack(Monitor *m); 33 +static void bstackhoriz(Monitor *m); 34 35 /* variables */ 36 static const char broken[] = "broken"; 37 @@ -2175,3 +2177,87 @@ main(int argc, char *argv[]) 38 XCloseDisplay(dpy); 39 return EXIT_SUCCESS; 40 } 41 + 42 +void 43 +bstack(Monitor *m) 44 +{ 45 + unsigned int i, n, w, mh, mx, tx; 46 + float mfacts = 0, sfacts = 0; 47 + Client *c; 48 + 49 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { 50 + if (n < m->nmaster) 51 + mfacts += c->cfact; 52 + else 53 + sfacts += c->cfact; 54 + } 55 + if (n == 0) 56 + return; 57 + if(n == 1){ 58 + c = nexttiled(m->clients); 59 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); 60 + return; 61 + } 62 + 63 + if (n > m->nmaster) 64 + mh = m->nmaster ? m->wh * m->mfact : 0; 65 + else 66 + mh = m->wh; 67 + for (i = 0, mx = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 68 + if (i < m->nmaster) { 69 + w = (m->ww - mx) * (c->cfact / mfacts); 70 + resize(c, m->wx + mx, m->wy, w - (2*c->bw), mh - 2*c->bw, 0); 71 + if(mx + WIDTH(c) < m->mw) 72 + mx += WIDTH(c); 73 + mfacts -= c->cfact; 74 + } else { 75 + w = (m->ww - tx) * (c->cfact / sfacts); 76 + resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*(c->bw), 0); 77 + if(tx + WIDTH(c) < m->mw) 78 + tx += WIDTH(c); 79 + sfacts -= c->cfact; 80 + } 81 +} 82 + 83 +void 84 +bstackhoriz(Monitor *m) 85 +{ 86 + unsigned int i, n, h, mw, mh, my, ty; 87 + float mfacts = 0, sfacts = 0; 88 + Client *c; 89 + 90 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { 91 + if (n < m->nmaster) 92 + mfacts += c->cfact; 93 + else 94 + sfacts += c->cfact; 95 + } 96 + if (n == 0) 97 + return; 98 + if(n == 1){ 99 + c = nexttiled(m->clients); 100 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); 101 + return; 102 + } 103 + 104 + if (n > m->nmaster) 105 + mh = m->nmaster ? m->wh * m->mfact : 0; 106 + else 107 + mh = m->wh; 108 + mw = m->ww; 109 + 110 + for (i = ty = 0, my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 111 + if (i < m->nmaster) { 112 + h = (mh - my) * (c->cfact / mfacts); 113 + resize(c, m->wx, m->wy + my, mw - 2*c->bw, h - 2*c->bw, 0); 114 + if(my + HEIGHT(c) < m->mh) 115 + my += HEIGHT(c); 116 + mfacts -= c->cfact; 117 + } else { 118 + h = (m->wh - mh - ty) * (c->cfact / sfacts); 119 + resize(c, m->wx, m->wy + mh + ty, mw - 2*c->bw, h - (2*c->bw), 0); 120 + if(ty + HEIGHT(c) < m->mh) 121 + ty += HEIGHT(c); 122 + sfacts -= c->cfact; 123 + } 124 +}