diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-10 11:54:03 +0200 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-10 11:54:03 +0200 |
commit | 95d01d54ff5ff3a39d1c0fb9ad1d0017f489f9f3 (patch) | |
tree | 040550993518c66c34ac58511f36635f07f57326 /dwm.c | |
parent | Added activetagindicator [Patch] (diff) | |
download | dwm-95d01d54ff5ff3a39d1c0fb9ad1d0017f489f9f3.tar.gz dwm-95d01d54ff5ff3a39d1c0fb9ad1d0017f489f9f3.tar.bz2 dwm-95d01d54ff5ff3a39d1c0fb9ad1d0017f489f9f3.zip |
Improved gaps patch
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/dwm.c b/dwm.c index c94c776..e60127e 100644 --- a/dwm.c +++ b/dwm.c @@ -52,8 +52,8 @@ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) -#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) -#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) +#define WIDTH(X) ((X)->w + 2 * (X)->bw) +#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TAGSLENGTH (LENGTH(tags)) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) @@ -121,6 +121,7 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + float gappx; /* gap between windows */ unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -647,6 +648,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); @@ -1249,29 +1251,13 @@ void resizeclient(Client *c, int x, int y, int w, int h) { XWindowChanges wc; - unsigned int n; - unsigned int gapoffset; - unsigned int gapincr; - Client *nbc; + c->oldx = c->x; c->x = wc.x = x; + c->oldy = c->y; c->y = wc.y = y; + c->oldw = c->w; c->w = wc.width = w; + c->oldh = c->h; c->h = wc.height = h; wc.border_width = c->bw; - /* Get number of clients for the selected monitor */ - for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++); - - /* Do nothing if layout is floating */ - if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) { - gapincr = gapoffset = 0; - } else { - gapoffset = gappx; - gapincr = 2 * gappx; - } - - c->oldx = c->x; c->x = wc.x = x + gapoffset; - c->oldy = c->y; c->y = wc.y = y + gapoffset; - c->oldw = c->w; c->w = wc.width = w - gapincr; - c->oldh = c->h; c->h = wc.height = h - gapincr; - XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); configure(c); XSync(dpy, False); @@ -1696,7 +1682,7 @@ tagmon(const Arg *arg) void tile(Monitor *m) { - unsigned int i, n, h, mw, my, ty; + unsigned int i, n, h, mw, my, ty, r; Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); @@ -1704,18 +1690,20 @@ tile(Monitor *m) return; if (n > m->nmaster) - mw = m->nmaster ? m->ww * m->mfact : 0; + mw = m->nmaster ? (m->ww + m->gappx) * 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 - 2*m->gappx + 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); - my += HEIGHT(c); + r = MIN(n, m->nmaster) - i; + h = (m->wh - my - m->gappx - m->gappx * (r - 1)) / r; + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); + 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); - ty += HEIGHT(c); + r = n - i; + h = (m->wh - ty - m->gappx - m->gappx * (r - 1)) / r; + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0); + ty += HEIGHT(c) + m->gappx; } } |