From 1647a70ea6f53e17625d00a91c7c388e1c5892e1 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Mon, 7 Feb 2022 12:42:39 -0700 Subject: added fullgaps --- .gitignore | 4 ++++ dwm.c | 37 +++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 0564216..bd6f44c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ *.o /patches +dwm +*.orig +*.rej +*.1 diff --git a/dwm.c b/dwm.c index e9b6234..187cc33 100644 --- a/dwm.c +++ b/dwm.c @@ -122,6 +122,7 @@ struct Monitor { int ty; /* tab bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + int gappx; unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -211,6 +212,7 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); +static void setgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -674,6 +676,7 @@ createmon(void) m->showbar = showbar; m->showtab = showtab; m->topbar = topbar; + m->gappx = gappx; m->toptab = toptab; m->ntabs = 0; m->lt[0] = &layouts[0]; @@ -1657,6 +1660,16 @@ setfullscreen(Client *c, int fullscreen) } } +void +setgaps(const Arg *arg) +{ + if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) + selmon->gappx = 0; + else + selmon->gappx += arg->i; + arrange(selmon); +} + void setlayout(const Arg *arg) { @@ -1834,7 +1847,7 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int i, n, h, r, g = 0, mw, my, ty; + unsigned int i, n, h, mw, my, ty; Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); @@ -1842,20 +1855,20 @@ tile(Monitor *m) return; if (n > m->nmaster) - mw = m->nmaster ? (m->ww - (g = gappx)) * m->mfact : 0; + mw = m->nmaster ? m->ww * m->mfact : 0; else - mw = m->ww; - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + mw = m->ww - m->gappx; + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) if (i < m->nmaster) { - r = MIN(n, m->nmaster) - i; - h = (m->wh - my - gappx * (r - 1)) / r; - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); - my += HEIGHT(c) + gappx; + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); + if (my + HEIGHT(c) + m->gappx < m->wh) + my += HEIGHT(c) + m->gappx; } else { - r = n - i; - h = (m->wh - ty - gappx * (r - 1)) / r; - resize(c, m->wx + mw + g, m->wy + ty, m->ww - mw - g - (2*c->bw), h - (2*c->bw), False); - ty += HEIGHT(c) + gappx; + h = (m->wh - ty) / (n - i) - m->gappx; + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h -(2*c->bw), 0); + if (ty + HEIGHT(c) + m->gappx < m->wh) + ty += HEIGHT(c) + m->gappx; } } -- cgit v1.2.3