dwm-tilewide-6.4.diff (2557B)
1 From bcd178cc2321c824080dfaad14c9c18462b05c06 Mon Sep 17 00:00:00 2001 2 From: sympodius <mail@sympodius.net> 3 Date: Fri, 10 Mar 2023 20:56:49 +0000 4 Subject: [PATCH] Patch tested for 6.4 release. 5 6 --- 7 config.def.h | 2 ++ 8 dwm.c | 29 +++++++++++++++++++++++++++++ 9 2 files changed, 31 insertions(+) 10 11 diff --git a/config.def.h b/config.def.h 12 index 9efa774..bbb5b1a 100644 13 --- a/config.def.h 14 +++ b/config.def.h 15 @@ -42,6 +42,7 @@ static const Layout layouts[] = { 16 { "[]=", tile }, /* first entry is default */ 17 { "><>", NULL }, /* no layout function means floating behavior */ 18 { "[M]", monocle }, 19 + { "[][]=", tilewide }, 20 }; 21 22 /* key definitions */ 23 @@ -77,6 +78,7 @@ static const Key keys[] = { 24 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 25 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 26 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 27 + { MODKEY, XK_w, setlayout, {.v = &layouts[3]} }, 28 { MODKEY, XK_space, setlayout, {0} }, 29 { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 30 { MODKEY, XK_0, view, {.ui = ~0 } }, 31 diff --git a/dwm.c b/dwm.c 32 index c2bd871..93a5156 100644 33 --- a/dwm.c 34 +++ b/dwm.c 35 @@ -209,6 +209,7 @@ static void spawn(const Arg *arg); 36 static void tag(const Arg *arg); 37 static void tagmon(const Arg *arg); 38 static void tile(Monitor *m); 39 +static void tilewide(Monitor *m); 40 static void togglebar(const Arg *arg); 41 static void togglefloating(const Arg *arg); 42 static void toggletag(const Arg *arg); 43 @@ -1704,6 +1705,34 @@ tile(Monitor *m) 44 } 45 } 46 47 +void 48 +tilewide(Monitor *m) 49 +{ 50 + unsigned int i, n, w, h, mw, mx, ty; 51 + Client *c; 52 + 53 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 54 + if (n == 0) 55 + return; 56 + 57 + if (n > m->nmaster) 58 + mw = m->nmaster ? m->ww * m->mfact : 0; 59 + else 60 + mw = m->ww; 61 + for (i = mx = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 62 + if (i < m->nmaster) { 63 + w = (mw - mx) / (MIN(n, m->nmaster) - i); 64 + resize(c, m->wx + mx, m->wy, w - (2*c->bw), (m->wh - ty) - (2*c->bw), 0); 65 + if (mx + WIDTH(c) < m->ww) 66 + mx += WIDTH(c); 67 + } else { 68 + h = (m->wh - ty) / (n - i); 69 + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); 70 + if (ty + HEIGHT(c) < m->wh) 71 + ty += HEIGHT(c); 72 + } 73 +} 74 + 75 void 76 togglebar(const Arg *arg) 77 { 78 -- 79 2.39.2 80