From f0792e4daf566be0304aad18e43d16c044844f16 Mon Sep 17 00:00:00 2001 From: Georgios Oxinos Date: Sun, 24 Jan 2021 16:38:28 +0100 Subject: [PATCH] [dwm][patch] patch that adds gaps to column layout --- config.def.h | 3 +++ dwm.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/config.def.h b/config.def.h index 1c0b587..a0305fc 100644 --- a/config.def.h +++ b/config.def.h @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ +static const unsigned int gappx = 12; /* gap pixel between windows */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; @@ -41,6 +42,7 @@ static const Layout layouts[] = { { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "|||", col }, }; /* key definitions */ @@ -76,6 +78,7 @@ 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_c, setlayout, {.v = &layouts[3]} }, { 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 4465af1..e72e00a 100644 --- a/dwm.c +++ b/dwm.c @@ -1670,6 +1670,35 @@ tagmon(const Arg *arg) sendmon(selmon->sel, dirtomon(arg->i)); } +void +col(Monitor *m) { + unsigned int i, n, h, w, x, y, mw; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + if(n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else + mw = m->ww - m->gappx; + + for(i = 0, x = y = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if(i < m->nmaster) { + w = (mw - x) / (MIN(n, m->nmaster) - i); + resize(c, x + m->wx, m->wy + m->gappx, w - (2*c->bw), m->wh - (2*c->bw) - 2*m->gappx, False); + if (x + WIDTH(c) + m->gappx < m->ww) + x += WIDTH(c) + m->gappx; + } else { + h = (m->wh - y) / (n - i) - m->gappx; + resize(c, x + m->wx, m->wy + y, m->ww - x - (2*c->bw) - m->gappx, h - (2*c->bw), False); + if (y + HEIGHT(c) + m->gappx < m->wh) + y += HEIGHT(c) + m->gappx; + } + } +} + void tile(Monitor *m) { -- 2.27.0