diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-27 14:24:10 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-27 14:56:06 +0300 |
commit | 7985c39e7f767fbdcc835c13c24455c96ba8e8d6 (patch) | |
tree | b250efc862b032d0aef1483860c3929d9de83a2f | |
parent | 20efe5c18c543cf29e92f07976fb2de0b796bf6b (diff) | |
download | dwm-7985c39e7f767fbdcc835c13c24455c96ba8e8d6.tar.gz |
feat: add gaps
-rw-r--r-- | config.def.h | 4 | ||||
-rw-r--r-- | dwm.1 | 10 | ||||
-rw-r--r-- | dwm.c | 33 |
3 files changed, 35 insertions, 12 deletions
diff --git a/config.def.h b/config.def.h index 0d645ea..623895f 100644 --- a/config.def.h +++ b/config.def.h @@ -2,7 +2,7 @@ /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int gappx = 5; /* gaps between windows */ +static const unsigned int gappx = 28; /* gaps between 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 */ @@ -29,7 +29,7 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + // TODO: figure out firefox { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, }; /* layout(s) */ @@ -140,6 +140,16 @@ View all windows with any tag. .B Mod1\-Control\-[1..n] Add/remove all windows with nth tag to/from the view. .TP +.B Mod1\-- +Decrease the gaps around windows. +.TP +.B Mod1\-= +Increase the gaps around windows. +.TP +.B Mod1\-Shift-= +Reset the gaps around windows to +.BR 0 . +.TP .B Mod1\-Shift\-q Quit dwm. .SS Mouse commands @@ -119,6 +119,7 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + int gappx; /* gaps between windows */ unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -200,6 +201,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); @@ -639,6 +641,7 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + m->gappx = gappx; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); @@ -1499,6 +1502,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) { if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) @@ -1684,18 +1697,18 @@ tile(Monitor *m) if (n > m->nmaster) 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) { - 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); - if (my + HEIGHT(c) < m->wh) - my += HEIGHT(c); + 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 { - 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); - if (ty + HEIGHT(c) < m->wh) - ty += HEIGHT(c); + 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; } } |