aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--dwm.c37
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];
@@ -1658,6 +1661,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])
@@ -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;
}
}