summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c155
1 files changed, 14 insertions, 141 deletions
diff --git a/dwm.c b/dwm.c
index 213c160..51867d1 100644
--- a/dwm.c
+++ b/dwm.c
@@ -137,10 +137,6 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
- int gappih; /* horizontal gap between windows */
- int gappiv; /* vertical gap between windows */
- int gappoh; /* horizontal outer gaps */
- int gappov; /* vertical outer gaps */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -230,16 +226,6 @@ 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(int oh, int ov, int ih, int iv);
-static void incrgaps(const Arg *arg);
-static void incrigaps(const Arg *arg);
-static void incrogaps(const Arg *arg);
-static void incrohgaps(const Arg *arg);
-static void incrovgaps(const Arg *arg);
-static void incrihgaps(const Arg *arg);
-static void incrivgaps(const Arg *arg);
-static void togglegaps(const Arg *arg);
-static void defaultgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -288,7 +274,6 @@ static char stext[256];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
-static int enablegaps = 1; /* enables gaps, used by togglegaps */
static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
@@ -740,10 +725,6 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
- m->gappih = gappih;
- m->gappiv = gappiv;
- m->gappoh = gappoh;
- m->gappov = gappov;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@@ -1658,111 +1639,6 @@ setfullscreen(Client *c, int fullscreen)
}
void
-setgaps(int oh, int ov, int ih, int iv)
-{
- if (oh < 0) oh = 0;
- if (ov < 0) ov = 0;
- if (ih < 0) ih = 0;
- if (iv < 0) iv = 0;
-
- selmon->gappoh = oh;
- selmon->gappov = ov;
- selmon->gappih = ih;
- selmon->gappiv = iv;
- arrange(selmon);
-}
-
-void
-togglegaps(const Arg *arg)
-{
- enablegaps = !enablegaps;
- arrange(selmon);
-}
-
-void
-defaultgaps(const Arg *arg)
-{
- setgaps(gappoh, gappov, gappih, gappiv);
-}
-
-void
-incrgaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh + arg->i,
- selmon->gappov + arg->i,
- selmon->gappih + arg->i,
- selmon->gappiv + arg->i
- );
-}
-
-void
-incrigaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh,
- selmon->gappov,
- selmon->gappih + arg->i,
- selmon->gappiv + arg->i
- );
-}
-
-void
-incrogaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh + arg->i,
- selmon->gappov + arg->i,
- selmon->gappih,
- selmon->gappiv
- );
-}
-
-void
-incrohgaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh + arg->i,
- selmon->gappov,
- selmon->gappih,
- selmon->gappiv
- );
-}
-
-void
-incrovgaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh,
- selmon->gappov + arg->i,
- selmon->gappih,
- selmon->gappiv
- );
-}
-
-void
-incrihgaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh,
- selmon->gappov,
- selmon->gappih + arg->i,
- selmon->gappiv
- );
-}
-
-void
-incrivgaps(const Arg *arg)
-{
- setgaps(
- selmon->gappoh,
- selmon->gappov,
- selmon->gappih,
- selmon->gappiv + arg->i
- );
-}
-
-void
setlayout(const Arg *arg)
{
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
@@ -1947,32 +1823,29 @@ tagmon(const Arg *arg)
void
tile(Monitor *m)
{
- unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, 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 (smartgaps == n) {
- oe = 0; // outer gaps disabled
+ if (n > m->nmaster) {
+ mw = m->nmaster ? m->ww * m->mfact : 0;
+ ns = m->nmaster > 0 ? 2 : 1;
+ } else {
+ mw = m->ww;
+ ns = 1;
}
-
- if (n > m->nmaster)
- mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0;
- else
- mw = m->ww - 2*m->gappov*oe + m->gappiv*ie;
- for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ for(i = 0, my = ty = 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 - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
- resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0);
- my += HEIGHT(c) + m->gappih*ie;
+ 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 {
- r = n - i;
- h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
- resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0);
- ty += HEIGHT(c) + m->gappih*ie;
+ 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;
}
}