Skip to content

Instantly share code, notes, and snippets.

@samrogerson
Created April 22, 2013 07:40
Show Gist options
  • Save samrogerson/5433094 to your computer and use it in GitHub Desktop.
Save samrogerson/5433094 to your computer and use it in GitHub Desktop.
Diff for git://git.suckless.org/dwm to make "useless gap" work on 6.0. Works only in the `tile` function.
diff --git a/config.def.h b/config.def.h
index 8fd5d4a..82b010e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -10,6 +10,7 @@ static const char selbgcolor[] = "#005577";
static const char selfgcolor[] = "#eeeeee";
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
+static const unsigned int tilespace = 6; /* spacing between tiles */
static const Bool showbar = True; /* False means no bar */
static const Bool topbar = True; /* False means bottom bar */
diff --git a/dwm.c b/dwm.c
index 7941bd1..e56b21e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1712,26 +1712,42 @@ textnw(const char *text, unsigned int len) {
void
tile(Monitor *m) {
- unsigned int i, n, h, mw, my, ty;
+ unsigned int i, n, h, mw, my, ty, ts, ys, xs;
Client *c;
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if(n == 0)
return;
- if(n > m->nmaster)
+ if(n > m->nmaster) {
mw = m->nmaster ? m->ww * m->mfact : 0;
- else
+ ts = m->nmaster ? tilespace * 1.5 : tilespace * 2;
+
+ } else {
mw = m->ww;
- for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ ts = tilespace * 2;
+ }
+
+ for(i = my = ty = ys = 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), False);
+ h = (m->wh - my - (MIN(n, m->nmaster) + 1) * tilespace) / (MIN(n, m->nmaster) - i) ;
+ ys = i * tilespace;
+ resize(c, m->wx + tilespace, m->wy + my + tilespace + ys,
+ mw - (2*c->bw) - ts, h - (2*c->bw), False);
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), False);
+ // m->nmaster > 1 yshift on tiles by nmaster * tilespace
+ h = (m->wh - ty - (n - m->nmaster + 1) * tilespace) / (n - i);
+ ys = (i-m->nmaster) * tilespace;
+ if(m->nmaster > 0) {
+ xs = 0.5 * tilespace;
+ } else {
+ xs = tilespace;
+ ys += tilespace;
+ }
+ resize(c, m->wx + mw + xs, m->wy + ty + tilespace + ys,
+ m->ww - mw - (2*c->bw) - ts, h - (2*c->bw), False);
ty += HEIGHT(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment