dwm-columngaps-20210124-f0792e4.diff (2964B)
1 From f0792e4daf566be0304aad18e43d16c044844f16 Mon Sep 17 00:00:00 2001 2 From: Georgios Oxinos <georgios.oxinos.extern@elinvar.de> 3 Date: Sun, 24 Jan 2021 16:38:28 +0100 4 Subject: [PATCH] [dwm][patch] patch that adds gaps to column layout 5 6 --- 7 config.def.h | 3 +++ 8 dwm.c | 29 +++++++++++++++++++++++++++++ 9 2 files changed, 32 insertions(+) 10 11 diff --git a/config.def.h b/config.def.h 12 index 1c0b587..a0305fc 100644 13 --- a/config.def.h 14 +++ b/config.def.h 15 @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ 16 static const unsigned int snap = 32; /* snap pixel */ 17 static const int showbar = 1; /* 0 means no bar */ 18 static const int topbar = 1; /* 0 means bottom bar */ 19 +static const unsigned int gappx = 12; /* gap pixel between windows */ 20 static const char *fonts[] = { "monospace:size=10" }; 21 static const char dmenufont[] = "monospace:size=10"; 22 static const char col_gray1[] = "#222222"; 23 @@ -41,6 +42,7 @@ static const Layout layouts[] = { 24 { "[]=", tile }, /* first entry is default */ 25 { "><>", NULL }, /* no layout function means floating behavior */ 26 { "[M]", monocle }, 27 + { "|||", col }, 28 }; 29 30 /* key definitions */ 31 @@ -76,6 +78,7 @@ static Key keys[] = { 32 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 33 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 34 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 35 + { MODKEY, XK_c, setlayout, {.v = &layouts[3]} }, 36 { MODKEY, XK_space, setlayout, {0} }, 37 { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 38 { MODKEY, XK_0, view, {.ui = ~0 } }, 39 diff --git a/dwm.c b/dwm.c 40 index 4465af1..e72e00a 100644 41 --- a/dwm.c 42 +++ b/dwm.c 43 @@ -1670,6 +1670,35 @@ tagmon(const Arg *arg) 44 sendmon(selmon->sel, dirtomon(arg->i)); 45 } 46 47 +void 48 +col(Monitor *m) { 49 + unsigned int i, n, h, w, x, y, mw; 50 + Client *c; 51 + 52 + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 53 + if(n == 0) 54 + return; 55 + 56 + if(n > m->nmaster) 57 + mw = m->nmaster ? m->ww * m->mfact : 0; 58 + else 59 + mw = m->ww - m->gappx; 60 + 61 + for(i = 0, x = y = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { 62 + if(i < m->nmaster) { 63 + w = (mw - x) / (MIN(n, m->nmaster) - i); 64 + resize(c, x + m->wx, m->wy + m->gappx, w - (2*c->bw), m->wh - (2*c->bw) - 2*m->gappx, False); 65 + if (x + WIDTH(c) + m->gappx < m->ww) 66 + x += WIDTH(c) + m->gappx; 67 + } else { 68 + h = (m->wh - y) / (n - i) - m->gappx; 69 + resize(c, x + m->wx, m->wy + y, m->ww - x - (2*c->bw) - m->gappx, h - (2*c->bw), False); 70 + if (y + HEIGHT(c) + m->gappx < m->wh) 71 + y += HEIGHT(c) + m->gappx; 72 + } 73 + } 74 +} 75 + 76 void 77 tile(Monitor *m) 78 { 79 -- 80 2.27.0 81