| dwm-columns-6.2.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dwm-columns-6.2.diff (2909B) | |
| --- | |
| 1 From 8394c430458713aa14dd8afdf86a9b14c646a1e7 Mon Sep 17 00:00:00 2001 | |
| 2 From: Louis Bettens <[email protected]> | |
| 3 Date: Thu, 2 Dec 2021 21:41:07 +0100 | |
| 4 Subject: [PATCH] columns | |
| 5 | |
| 6 This patch adds an extra layout to dwm called `col` in which the windows… | |
| 7 master area are arranged in colums of equal size. The number of columns … | |
| 8 always nmaster + 1, and the last column is a stack of leftover windows j… | |
| 9 like the normal tile layout. It effectively acts like the default tiling… | |
| 10 except provides for vertical instead of horizontal master windows. | |
| 11 | |
| 12 Co-authored-by: Evan Gates (emg) <[email protected]> | |
| 13 Co-authored-by: Noah Rosser <[email protected]> | |
| 14 --- | |
| 15 config.def.h | 2 ++ | |
| 16 dwm.c | 27 +++++++++++++++++++++++++++ | |
| 17 2 files changed, 29 insertions(+) | |
| 18 | |
| 19 diff --git a/config.def.h b/config.def.h | |
| 20 index 1c0b587..de7a2e7 100644 | |
| 21 --- a/config.def.h | |
| 22 +++ b/config.def.h | |
| 23 @@ -41,6 +41,7 @@ static const Layout layouts[] = { | |
| 24 { "[]=", tile }, /* first entry is default */ | |
| 25 { "><>", NULL }, /* no layout function means floating b… | |
| 26 { "[M]", monocle }, | |
| 27 + { "|||", col }, | |
| 28 }; | |
| 29 | |
| 30 /* key definitions */ | |
| 31 @@ -76,6 +77,7 @@ static Key keys[] = { | |
| 32 { MODKEY, XK_t, setlayout, {.v … | |
| 33 { MODKEY, XK_f, setlayout, {.v … | |
| 34 { MODKEY, XK_m, setlayout, {.v … | |
| 35 + { MODKEY, XK_c, setlayout, {.v … | |
| 36 { MODKEY, XK_space, setlayout, {0} … | |
| 37 { MODKEY|ShiftMask, XK_space, togglefloating, {0} … | |
| 38 { MODKEY, XK_0, view, {.ui… | |
| 39 diff --git a/dwm.c b/dwm.c | |
| 40 index 4465af1..b5845c9 100644 | |
| 41 --- a/dwm.c | |
| 42 +++ b/dwm.c | |
| 43 @@ -153,6 +153,7 @@ static void checkotherwm(void); | |
| 44 static void cleanup(void); | |
| 45 static void cleanupmon(Monitor *mon); | |
| 46 static void clientmessage(XEvent *e); | |
| 47 +static void col(Monitor *); | |
| 48 static void configure(Client *c); | |
| 49 static void configurenotify(XEvent *e); | |
| 50 static void configurerequest(XEvent *e); | |
| 51 @@ -1670,6 +1671,32 @@ tagmon(const Arg *arg) | |
| 52 sendmon(selmon->sel, dirtomon(arg->i)); | |
| 53 } | |
| 54 | |
| 55 +void | |
| 56 +col(Monitor *m) | |
| 57 +{ | |
| 58 + unsigned int i, n, h, w, x, y, mw; | |
| 59 + Client *c; | |
| 60 + | |
| 61 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next… | |
| 62 + if (n == 0) | |
| 63 + return; | |
| 64 + | |
| 65 + if (n > m->nmaster) | |
| 66 + mw = m->nmaster ? m->ww * m->mfact : 0; | |
| 67 + else | |
| 68 + mw = m->ww; | |
| 69 + for (i = x = y = 0, c = nexttiled(m->clients); c; c = nexttiled… | |
| 70 + if (i < m->nmaster) { | |
| 71 + w = (mw - x) / (MIN(n, m->nmaster) - i); | |
| 72 + resize(c, x + m->wx, m->wy, w - (2 * c->bw), m-… | |
| 73 + x += WIDTH(c); | |
| 74 + } else { | |
| 75 + h = (m->wh - y) / (n - i); | |
| 76 + resize(c, x + m->wx, m->wy + y, m->ww - x - (2 … | |
| 77 + y += HEIGHT(c); | |
| 78 + } | |
| 79 +} | |
| 80 + | |
| 81 void | |
| 82 tile(Monitor *m) | |
| 83 { | |
| 84 -- | |
| 85 2.34.0 | |
| 86 |