diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-25 16:07:12 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-25 16:07:12 +0200 |
commit | 300a8ee9fb7680e074b5a017110d685ad0356030 (patch) | |
tree | 6ebf01d98b8b9a223b74260dca1a7f27a608e0a3 | |
parent | readability update (diff) | |
download | dwm-300a8ee9fb7680e074b5a017110d685ad0356030.tar.gz dwm-300a8ee9fb7680e074b5a017110d685ad0356030.tar.bz2 dwm-300a8ee9fb7680e074b5a017110d685ad0356030.tar.xz dwm-300a8ee9fb7680e074b5a017110d685ad0356030.tar.zst dwm-300a8ee9fb7680e074b5a017110d685ad0356030.zip |
btmstck update
-rw-r--r-- | applied/dwm-bottomstack-6.1.diff | 101 | ||||
-rw-r--r-- | config.def.h | 6 | ||||
-rw-r--r-- | config.h | 6 | ||||
-rw-r--r-- | dwm.c | 64 |
4 files changed, 175 insertions, 2 deletions
diff --git a/applied/dwm-bottomstack-6.1.diff b/applied/dwm-bottomstack-6.1.diff new file mode 100644 index 0000000..9fdffd5 --- /dev/null +++ b/applied/dwm-bottomstack-6.1.diff @@ -0,0 +1,101 @@ +diff --git a/config.def.h b/config.def.h +index 7054c06..554f1db 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -39,6 +39,8 @@ static const Layout layouts[] = { + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "TTT", bstack }, ++ { "===", bstackhoriz }, + }; + + /* key definitions */ +@@ -74,6 +76,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 --git a/dwm.c b/dwm.c +index 0362114..c313b5e 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -233,6 +233,8 @@ static int xerror(Display *dpy, XErrorEvent *ee); + 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"; +@@ -2139,3 +2141,65 @@ main(int argc, char *argv[]) + XCloseDisplay(dpy); + return EXIT_SUCCESS; + } ++ ++static void ++bstack(Monitor *m) { ++ int w, h, mh, mx, tx, ty, tw; ++ unsigned int i, n; ++ Client *c; ++ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); ++ if (n == 0) ++ return; ++ if (n > m->nmaster) { ++ mh = m->nmaster ? m->mfact * m->wh : 0; ++ tw = m->ww / (n - m->nmaster); ++ ty = m->wy + mh; ++ } else { ++ mh = m->wh; ++ tw = m->ww; ++ ty = m->wy; ++ } ++ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { ++ if (i < m->nmaster) { ++ w = (m->ww - mx) / (MIN(n, m->nmaster) - i); ++ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); ++ mx += WIDTH(c); ++ } else { ++ h = m->wh - mh; ++ resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); ++ if (tw != m->ww) ++ tx += WIDTH(c); ++ } ++ } ++} ++ ++static void ++bstackhoriz(Monitor *m) { ++ int w, mh, mx, tx, ty, th; ++ unsigned int i, n; ++ Client *c; ++ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); ++ if (n == 0) ++ return; ++ if (n > m->nmaster) { ++ mh = m->nmaster ? m->mfact * m->wh : 0; ++ th = (m->wh - mh) / (n - m->nmaster); ++ ty = m->wy + mh; ++ } else { ++ th = mh = m->wh; ++ ty = m->wy; ++ } ++ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { ++ if (i < m->nmaster) { ++ w = (m->ww - mx) / (MIN(n, m->nmaster) - i); ++ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); ++ mx += WIDTH(c); ++ } else { ++ resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); ++ if (th != m->wh) ++ ty += HEIGHT(c); ++ } ++ } ++} diff --git a/config.def.h b/config.def.h index cdca826..847cd05 100644 --- a/config.def.h +++ b/config.def.h @@ -67,6 +67,8 @@ static const Layout layouts[] = { { "|M|", centeredmaster }, { ">M>", centeredfloatingmaster }, { "[M]", monocle }, + { "TTT", bstack }, + { "===", bstackhoriz }, { "><>", NULL }, /* no layout function means floating behavior */ }; @@ -190,7 +192,9 @@ static Key keys[] = { { MODKEY, XK_c, setlayout, {.v = &layouts[1]} }, /* centeredmaster */ { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, /* centeredfloatingmaster */ { MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, /* monocle */ - { MODKEY, XK_n, setlayout, {.v = &layouts[4]} }, /* floating */ + { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[4]} }, /* bottoastack */ + { MODKEY, XK_t, setlayout, {.v = &layouts[5]} }, /* bottomstackhoriz */ + { MODKEY, XK_n, setlayout, {.v = &layouts[6]} }, /* floating */ { MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY, XK_space, togglefloating, {0} }, { MODKEY, XK_f, togglefullscr, {0} }, @@ -67,6 +67,8 @@ static const Layout layouts[] = { { "|M|", centeredmaster }, { ">M>", centeredfloatingmaster }, { "[M]", monocle }, + { "TTT", bstack }, + { "===", bstackhoriz }, { "><>", NULL }, /* no layout function means floating behavior */ }; @@ -190,7 +192,9 @@ static Key keys[] = { { MODKEY, XK_c, setlayout, {.v = &layouts[1]} }, /* centeredmaster */ { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, /* centeredfloatingmaster */ { MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, /* monocle */ - { MODKEY, XK_n, setlayout, {.v = &layouts[4]} }, /* floating */ + { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[4]} }, /* bottoastack */ + { MODKEY, XK_t, setlayout, {.v = &layouts[5]} }, /* bottomstackhoriz */ + { MODKEY, XK_n, setlayout, {.v = &layouts[6]} }, /* floating */ { MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY, XK_space, togglefloating, {0} }, { MODKEY, XK_f, togglefullscr, {0} }, @@ -251,6 +251,8 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); static void centeredmaster(Monitor *m); static void centeredfloatingmaster(Monitor *m); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); /* variables */ static const char broken[] = "broken"; @@ -2482,6 +2484,68 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; } +static void +bstack(Monitor *m) { + int w, h, mh, mx, tx, ty, tw; + unsigned int i, n; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + tw = m->ww / (n - m->nmaster); + ty = m->wy + mh; + } else { + mh = m->wh; + tw = m->ww; + ty = m->wy; + } + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += WIDTH(c); + } else { + h = m->wh - mh; + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); + if (tw != m->ww) + tx += WIDTH(c); + } + } +} + +static void +bstackhoriz(Monitor *m) { + int w, mh, mx, tx, ty, th; + unsigned int i, n; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + th = (m->wh - mh) / (n - m->nmaster); + ty = m->wy + mh; + } else { + th = mh = m->wh; + ty = m->wy; + } + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += WIDTH(c); + } else { + resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); + if (th != m->wh) + ty += HEIGHT(c); + } + } +} + void centeredmaster(Monitor *m) { |