diff --git a/README.md b/README.md index 516d8e8..da4793b 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2019-09-09 - Added deck, fibonacci (dwindle and spiral) layouts + 2019-09-08 - Added cfacts and vanitygaps patches, added bstack and bstackhoriz layouts 2019-09-07 - Added cyclelayouts, resizecorners, rotatestack, savefloats, statuspadding, switchtag, center and windowrolerule patches @@ -114,4 +116,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - bottomstack horizontal layout - [deck](https://dwm.suckless.org/patches/deck/) - - deck layout \ No newline at end of file + - deck layout + + - [fibonacci](https://dwm.suckless.org/patches/fibonacci/) + - fibonacci (dwindle and spiral) layouts \ No newline at end of file diff --git a/config.def.h b/config.def.h index 6e9f373..648454b 100644 --- a/config.def.h +++ b/config.def.h @@ -111,6 +111,12 @@ static const Layout layouts[] = { #if DECK_LAYOUT { "[D]", deck }, #endif // DECK_LAYOUT + #if FIBONACCI_SPIRAL_LAYOUT + { "(@)", spiral }, + #endif // FIBONACCI_SPIRAL_LAYOUT + #if FIBONACCI_DWINDLE_LAYOUT + { "[\\]", dwindle }, + #endif // FIBONACCI_DWINDLE_LAYOUT #if CYCLELAYOUTS_PATCH { NULL, NULL }, #endif // CYCLELAYOUTS_PATCH diff --git a/patch/fibonacci.c b/patch/fibonacci.c new file mode 100644 index 0000000..d989078 --- /dev/null +++ b/patch/fibonacci.c @@ -0,0 +1,144 @@ +#if VANITYGAPS_PATCH +static void +fibonacci(Monitor *m, int s) +{ + unsigned int i, n; + int nx, ny, nw, nh; + int oh, ov, ih, iv; + #if CFACTS_PATCH + float mfacts, sfacts; + #endif // CFACTS_PATCH + Client *c; + + #if CFACTS_PATCH + getgaps(m, &oh, &ov, &ih, &iv, &n, &mfacts, &sfacts); + #else + getgaps(m, &oh, &ov, &ih, &iv, &n); + #endif // CFACTS_PATCH + + if (n == 0) + return; + + nx = m->wx + ov; + ny = oh; + nw = m->ww - 2*ov; + nh = m->wh - 2*oh; + + for (i = 0, c = nexttiled(m->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 = (nh - ih) / 2; + else + nw = (nw - iv) / 2; + + if ((i % 4) == 2 && !s) + nx += nw + iv; + else if ((i % 4) == 3 && !s) + ny += nh + ih; + } + if ((i % 4) == 0) { + if (s) + ny += nh + ih; + else + ny -= nh + ih; + } + else if ((i % 4) == 1) + nx += nw + iv; + else if ((i % 4) == 2) + ny += nh + ih; + else if ((i % 4) == 3) { + if (s) + nx += nw + iv; + else + nx -= nw + iv; + } + if (i == 0) { + if (n != 1) + nw = (m->ww - 2*ov - iv) * m->mfact; + ny = m->wy + oh; + } + else if (i == 1) + nw = m->ww - nw - iv - 2*ov; + i++; + } + + resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); + } +} +#else +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; + + nx = mon->wx; + ny = 0; + 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; + } + else if (i == 1) + nw = mon->ww - nw; + i++; + } + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); + } +} +#endif + +#if FIBONACCI_DWINDLE_LAYOUT +static void +dwindle(Monitor *m) +{ + fibonacci(m, 1); +} +#endif + +#if FIBONACCI_SPIRAL_LAYOUT +static void +spiral(Monitor *m) +{ + fibonacci(m, 0); +} +#endif \ No newline at end of file diff --git a/patch/fibonacci.h b/patch/fibonacci.h new file mode 100644 index 0000000..ee46fe7 --- /dev/null +++ b/patch/fibonacci.h @@ -0,0 +1,3 @@ +static void dwindle(Monitor *m); +static void fibonacci(Monitor *m, int s); +static void spiral(Monitor *m); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 3eedd7a..7dc0aac 100644 --- a/patch/include.c +++ b/patch/include.c @@ -66,6 +66,10 @@ #include "deck.c" #endif +#if FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT +#include "fibonacci.c" +#endif + #if MONOCLE_LAYOUT #include "monocle.c" #endif diff --git a/patch/include.h b/patch/include.h index 3618492..af229ea 100644 --- a/patch/include.h +++ b/patch/include.h @@ -62,6 +62,10 @@ #include "deck.h" #endif +#if FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT +#include "fibonacci.h" +#endif + #if MONOCLE_LAYOUT #include "monocle.h" #endif diff --git a/patches.h b/patches.h index 50115d3..1c5df12 100644 --- a/patches.h +++ b/patches.h @@ -200,7 +200,17 @@ /* Deck layout. * https://dwm.suckless.org/patches/deck/ */ -#define DECK_LAYOUT 1 +#define DECK_LAYOUT 0 + +/* Fibonacci dwindle layout. + * https://dwm.suckless.org/patches/fibonacci/ + */ +#define FIBONACCI_DWINDLE_LAYOUT 0 + +/* Fibonacci spiral layout. + * https://dwm.suckless.org/patches/fibonacci/ + */ +#define FIBONACCI_SPIRAL_LAYOUT 0 /* The default tile layout. * This can be optionally disabled in favour of other layouts.