--- a/config.h 2018-02-15 15:39:21.682625300 -0500 +++ b/config.h 2018-02-15 15:41:19.860058000 -0500 @@ -3,6 +3,7 @@ /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int gappx = 18; /* gap pixel between windows */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { "monospace:size=10" }; --- a/dwm.c 2018-02-15 15:39:31.769237600 -0500 +++ b/dwm.c 2018-02-15 15:50:39.404250200 -0500 @@ -1674,26 +1674,29 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int i, n, h, mw, my, ty; + unsigned int i, n, h, mw, my, ty, ns; Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); if (n == 0) return; - if (n > m->nmaster) + if (n > m->nmaster) { mw = m->nmaster ? m->ww * m->mfact : 0; - else + ns = m->nmaster > 0 ? 2 : 1; + } else { mw = m->ww; - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + ns = 1; + } + for(i = 0, my = ty = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) if (i < m->nmaster) { - h = (m->wh - my) / (MIN(n, m->nmaster) - i); - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); - my += HEIGHT(c); + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx; + resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False); + my += HEIGHT(c) + gappx; } else { - h = (m->wh - ty) / (n - i); - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - ty += HEIGHT(c); + h = (m->wh - ty) / (n - i) - gappx; + resize(c, m->wx + mw + gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False); + ty += HEIGHT(c) + gappx; } }