This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* diff file for gaps in dwm fibonacci mode */ | |
diff -up a/config.def.h b/config.def.h | |
--- a/config.def.h 2019-02-02 13:55:28.000000000 +0100 | |
+++ b/config.def.h 2020-04-14 14:53:13.966170662 +0200 | |
@@ -2,6 +2,7 @@ | |
/* appearance */ | |
static const unsigned int borderpx = 1; /* border pixel of windows */ | |
+static const unsigned int gappx = 5; /* gaps between windows */ | |
static const unsigned int snap = 32; /* snap pixel */ | |
static const int showbar = 1; /* 0 means no bar */ | |
static const int topbar = 1; /* 0 means bottom bar */ | |
@@ -36,11 +37,14 @@ static const float mfact = 0.55; /* | |
static const int nmaster = 1; /* number of clients in master area */ | |
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ | |
+#include "fibonacci.c" | |
static const Layout layouts[] = { | |
/* symbol arrange function */ | |
{ "[]=", tile }, /* first entry is default */ | |
{ "><>", NULL }, /* no layout function means floating behavior */ | |
{ "[M]", monocle }, | |
+ { "[@]", spiral }, | |
+ { "[\\]", dwindle }, | |
}; | |
/* key definitions */ | |
@@ -84,6 +88,9 @@ static Key keys[] = { | |
{ MODKEY, XK_period, focusmon, {.i = +1 } }, | |
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, | |
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, | |
+ { MODKEY, XK_minus, setgaps, {.i = -5 } }, | |
+ { MODKEY, XK_equal, setgaps, {.i = +5 } }, | |
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, | |
TAGKEYS( XK_1, 0) | |
TAGKEYS( XK_2, 1) | |
TAGKEYS( XK_3, 2) | |
diff -up a/dwm.c b/dwm.c | |
--- a/dwm.c 2019-02-02 13:55:28.000000000 +0100 | |
+++ b/dwm.c 2020-04-14 14:47:45.941408612 +0200 | |
@@ -119,6 +119,7 @@ struct Monitor { | |
int by; /* bar geometry */ | |
int mx, my, mw, mh; /* screen size */ | |
int wx, wy, ww, wh; /* window area */ | |
+ int gappx; /* gaps between windows */ | |
unsigned int seltags; | |
unsigned int sellt; | |
unsigned int tagset[2]; | |
@@ -199,6 +200,7 @@ static void sendmon(Client *c, Monitor * | |
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); | |
@@ -638,6 +640,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); | |
@@ -1282,6 +1285,13 @@ resizeclient(Client *c, int x, int y, in | |
c->oldw = c->w; c->w = wc.width = w; | |
c->oldh = c->h; c->h = wc.height = h; | |
wc.border_width = c->bw; | |
+ if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) | |
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange)) | |
+ { | |
+ c->w = wc.width += c->bw * 2; | |
+ c->h = wc.height += c->bw * 2; | |
+ wc.border_width = 0; | |
+ } | |
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); | |
configure(c); | |
XSync(dpy, False); | |
@@ -1498,6 +1508,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]) | |
@@ -1673,26 +1693,35 @@ tagmon(const Arg *arg) | |
void | |
tile(Monitor *m) | |
{ | |
- unsigned int i, n, h, 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(n == 1){ | |
+ c = nexttiled(m->clients); | |
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); | |
+ return; | |
+ } | |
- if (n > m->nmaster) | |
+ 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++) | |
+ ns = m->nmaster > 0 ? 2 : 1; | |
+ } | |
+ else{ | |
+ mw = m->ww - m->gappx; | |
+ ns = 1; | |
+ } | |
+ 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); | |
+ 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*(5-ns)/2, 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); | |
+ h = (m->wh - ty) / (n - i) - m->gappx; | |
+ resize(c, m->wx + mw + m->gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, h - 2*c->bw, 0); | |
+ ty += HEIGHT(c) + m->gappx; | |
} | |
} | |
diff -up a/fibonacci.c b/fibonacci.c | |
--- a/fibonacci.c 2020-04-14 03:43:06.170901553 +0200 | |
+++ b/fibonacci.c 2020-04-14 14:51:52.657850423 +0200 | |
@@ -0,0 +1,75 @@ | |
+void fibonacci(Monitor *mon, int s) { | |
+ unsigned int i, n, nx, ny, nw, nh; | |
+ Client *c; | |
+ | |
+ for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); | |
+ if(n == 0) | |
+ return; | |
+ if(n == 1){ | |
+ c = nexttiled(mon->clients); | |
+ resize(c, mon->wx + mon->gappx, mon->wy + mon->gappx, (mon->ww - 2 * | |
+ c->bw) - 2 * mon->gappx, (mon->wh - 2 * c->bw) - 2 * | |
+ mon->gappx, 0); | |
+ return; | |
+ } | |
+ | |
+ nx = mon->wx; | |
+ ny = mon->gappx; | |
+ nw = mon->ww; | |
+ nh = mon->wh; | |
+ | |
+ for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { | |
+ if((i % 2 && nh / 2 > 2 * c->bw) | |
+ || (!(i % 2) && nw / 2 > 2 * c->bw)) { | |
+ if(i < n - 1) { | |
+ if(i % 2) | |
+ nh /= 2; | |
+ else | |
+ nw /= 2; | |
+ if((i % 4) == 2 && !s) | |
+ nx += nw; | |
+ else if((i % 4) == 3 && !s) | |
+ ny += nh; | |
+ } | |
+ if((i % 4) == 0) { | |
+ if(s) | |
+ ny += nh; | |
+ else | |
+ ny -= nh; | |
+ } | |
+ else if((i % 4) == 1) | |
+ nx += nw; | |
+ else if((i % 4) == 2) | |
+ ny += nh; | |
+ else if((i % 4) == 3) { | |
+ if(s) | |
+ nx += nw; | |
+ else | |
+ nx -= nw; | |
+ } | |
+ if(i == 0) | |
+ { | |
+ if(n != 1) | |
+ nw = mon->ww * mon->mfact; | |
+ ny = mon->wy + mon->gappx; | |
+ } | |
+ else if(i == 1) | |
+ nw = mon->ww - nw - mon->gappx; | |
+ i++; | |
+ } | |
+ if((s == 0 && i <= 4 && (i!=2 || n==2)) || (s==1 && (i%2==1 || i==n))) | |
+ resize(c, nx + mon->gappx, ny, nw - 2 * (c->bw) - mon->gappx, nh - 2 * (c->bw) - 2*mon->gappx, False); | |
+ else | |
+ resize(c, nx + mon->gappx, ny, nw - 2 * (c->bw) - mon->gappx, nh - 2 * (c->bw) - mon->gappx, False); | |
+ } | |
+} | |
+ | |
+void | |
+dwindle(Monitor *mon) { | |
+ fibonacci(mon, 1); | |
+} | |
+ | |
+void | |
+spiral(Monitor *mon) { | |
+ fibonacci(mon, 0); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment