diff --git a/config.def.h b/config.def.h index 671ae1f..8b868db 100644 --- a/config.def.h +++ b/config.def.h @@ -2,6 +2,8 @@ /* appearance */ static const unsigned int borderpx = 5; /* border pixel of windows */ +// add gappx +static const unsigned int gappx = 8; static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 0; /* 0 means bottom bar */ @@ -47,7 +49,7 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod1Mask +#define MODKEY Mod4Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ @@ -117,6 +119,8 @@ static const Key keys[] = { { MODKEY|ControlMask, XK_b, spawn, {.v = bgselectcmd } }, { MODKEY|ControlMask|ShiftMask, XK_a, spawn, {.v = audioswitchcmd } }, { MODKEY|ControlMask|ShiftMask, XK_d, spawn, {.v = displayctlcmd } }, + { MODKEY|ShiftMask, XK_minus, setgaps, {.i = -1 } }, + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = +1 } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, diff --git a/dwm.c b/dwm.c index 8d7a9f0..692a7e2 100644 --- a/dwm.c +++ b/dwm.c @@ -119,6 +119,8 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + // add gappx field + int gappx; unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -201,6 +203,8 @@ static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); static void setlayout(const Arg *arg); +// declare here +static void setgaps(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); @@ -656,6 +660,8 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + // add gappx here + m->gappx = gappx; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); @@ -1498,6 +1504,17 @@ setfocus(Client *c) sendevent(c, wmatom[WMTakeFocus]); } +// add setgaps function +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 setfullscreen(Client *c, int fullscreen) { @@ -1537,7 +1554,7 @@ setlayout(const Arg *arg) if (selmon->sel) arrange(selmon); else - drawbar(selmon); + drawbar(selmon); } /* arg > 1.0 will set mfact absolutely */ @@ -1703,6 +1720,35 @@ tagmon(const Arg *arg) sendmon(selmon->sel, dirtomon(arg->i)); } +//void +//tile(Monitor *m) +//{ +// unsigned int i, n, h, mw, my, ty; +// 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; +// for (i = my = ty = 0, 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); +// } 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); +// } +//} + +// new version, previous is above void tile(Monitor *m) { @@ -1716,18 +1762,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++) - 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); + 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) - 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; } }