dwm-bottomstack-20160719-56a31dc.diff (3165B)
1 diff --git a/config.def.h b/config.def.h 2 index fd77a07..c3a044b 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -41,6 +41,8 @@ static const Layout layouts[] = { 6 { "[]=", tile }, /* first entry is default */ 7 { "><>", NULL }, /* no layout function means floating behavior */ 8 { "[M]", monocle }, 9 + { "TTT", bstack }, 10 + { "===", bstackhoriz }, 11 }; 12 13 /* key definitions */ 14 @@ -76,6 +78,8 @@ static Key keys[] = { 15 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 16 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 17 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 18 + { MODKEY, XK_u, setlayout, {.v = &layouts[3]} }, 19 + { MODKEY, XK_o, setlayout, {.v = &layouts[4]} }, 20 { MODKEY, XK_space, setlayout, {0} }, 21 { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 22 { MODKEY, XK_0, view, {.ui = ~0 } }, 23 diff --git a/dwm.c b/dwm.c 24 index b2bc9bd..8b74165 100644 25 --- a/dwm.c 26 +++ b/dwm.c 27 @@ -234,6 +234,8 @@ static int xerror(Display *dpy, XErrorEvent *ee); 28 static int xerrordummy(Display *dpy, XErrorEvent *ee); 29 static int xerrorstart(Display *dpy, XErrorEvent *ee); 30 static void zoom(const Arg *arg); 31 +static void bstack(Monitor *m); 32 +static void bstackhoriz(Monitor *m); 33 34 /* variables */ 35 static const char broken[] = "broken"; 36 @@ -2138,3 +2140,65 @@ main(int argc, char *argv[]) 37 XCloseDisplay(dpy); 38 return EXIT_SUCCESS; 39 } 40 + 41 +static void 42 +bstack(Monitor *m) { 43 + int w, h, mh, mx, tx, ty, tw; 44 + unsigned int i, n; 45 + Client *c; 46 + 47 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 48 + if (n == 0) 49 + return; 50 + if (n > m->nmaster) { 51 + mh = m->nmaster ? m->mfact * m->wh : 0; 52 + tw = m->ww / (n - m->nmaster); 53 + ty = m->wy + mh; 54 + } else { 55 + mh = m->wh; 56 + tw = m->ww; 57 + ty = m->wy; 58 + } 59 + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { 60 + if (i < m->nmaster) { 61 + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); 62 + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); 63 + mx += WIDTH(c); 64 + } else { 65 + h = m->wh - mh; 66 + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); 67 + if (tw != m->ww) 68 + tx += WIDTH(c); 69 + } 70 + } 71 +} 72 + 73 +static void 74 +bstackhoriz(Monitor *m) { 75 + int w, mh, mx, tx, ty, th; 76 + unsigned int i, n; 77 + Client *c; 78 + 79 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 80 + if (n == 0) 81 + return; 82 + if (n > m->nmaster) { 83 + mh = m->nmaster ? m->mfact * m->wh : 0; 84 + th = (m->wh - mh) / (n - m->nmaster); 85 + ty = m->wy + mh; 86 + } else { 87 + th = mh = m->wh; 88 + ty = m->wy; 89 + } 90 + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { 91 + if (i < m->nmaster) { 92 + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); 93 + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); 94 + mx += WIDTH(c); 95 + } else { 96 + resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); 97 + if (th != m->wh) 98 + ty += HEIGHT(c); 99 + } 100 + } 101 +}