| dwm-fibonacci-6.2.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dwm-fibonacci-6.2.diff (3066B) | |
| --- | |
| 1 From ec9f55b6005cfa3b025b3d700c61af3ce539d057 Mon Sep 17 00:00:00 2001 | |
| 2 From: Niki Yoshiuchi <[email protected]> | |
| 3 Date: Sat, 18 Apr 2020 09:55:26 -0700 | |
| 4 Subject: [PATCH] Adding the fibonacci layout patch | |
| 5 | |
| 6 --- | |
| 7 config.def.h | 5 ++++ | |
| 8 fibonacci.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| 9 2 files changed, 71 insertions(+) | |
| 10 create mode 100644 fibonacci.c | |
| 11 | |
| 12 diff --git a/config.def.h b/config.def.h | |
| 13 index 1c0b587..5708487 100644 | |
| 14 --- a/config.def.h | |
| 15 +++ b/config.def.h | |
| 16 @@ -36,11 +36,14 @@ static const float mfact = 0.55; /* factor of ma… | |
| 17 static const int nmaster = 1; /* number of clients in master are… | |
| 18 static const int resizehints = 1; /* 1 means respect size hints in t… | |
| 19 | |
| 20 +#include "fibonacci.c" | |
| 21 static const Layout layouts[] = { | |
| 22 /* symbol arrange function */ | |
| 23 { "[]=", tile }, /* first entry is default */ | |
| 24 { "><>", NULL }, /* no layout function means floating b… | |
| 25 { "[M]", monocle }, | |
| 26 + { "[@]", spiral }, | |
| 27 + { "[\\]", dwindle }, | |
| 28 }; | |
| 29 | |
| 30 /* key definitions */ | |
| 31 @@ -76,6 +79,8 @@ static Key keys[] = { | |
| 32 { MODKEY, XK_t, setlayout, {.v … | |
| 33 { MODKEY, XK_f, setlayout, {.v … | |
| 34 { MODKEY, XK_m, setlayout, {.v … | |
| 35 + { MODKEY, XK_r, setlayout, {.v … | |
| 36 + { MODKEY|ShiftMask, XK_r, setlayout, {.v … | |
| 37 { MODKEY, XK_space, setlayout, {0} … | |
| 38 { MODKEY|ShiftMask, XK_space, togglefloating, {0} … | |
| 39 { MODKEY, XK_0, view, {.ui… | |
| 40 diff --git a/fibonacci.c b/fibonacci.c | |
| 41 new file mode 100644 | |
| 42 index 0000000..fce0a57 | |
| 43 --- /dev/null | |
| 44 +++ b/fibonacci.c | |
| 45 @@ -0,0 +1,66 @@ | |
| 46 +void | |
| 47 +fibonacci(Monitor *mon, int s) { | |
| 48 + unsigned int i, n, nx, ny, nw, nh; | |
| 49 + Client *c; | |
| 50 + | |
| 51 + for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->nex… | |
| 52 + if(n == 0) | |
| 53 + return; | |
| 54 + | |
| 55 + nx = mon->wx; | |
| 56 + ny = 0; | |
| 57 + nw = mon->ww; | |
| 58 + nh = mon->wh; | |
| 59 + | |
| 60 + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->nex… | |
| 61 + if((i % 2 && nh / 2 > 2 * c->bw) | |
| 62 + || (!(i % 2) && nw / 2 > 2 * c->bw)) { | |
| 63 + if(i < n - 1) { | |
| 64 + if(i % 2) | |
| 65 + nh /= 2; | |
| 66 + else | |
| 67 + nw /= 2; | |
| 68 + if((i % 4) == 2 && !s) | |
| 69 + nx += nw; | |
| 70 + else if((i % 4) == 3 && !s) | |
| 71 + ny += nh; | |
| 72 + } | |
| 73 + if((i % 4) == 0) { | |
| 74 + if(s) | |
| 75 + ny += nh; | |
| 76 + else | |
| 77 + ny -= nh; | |
| 78 + } | |
| 79 + else if((i % 4) == 1) | |
| 80 + nx += nw; | |
| 81 + else if((i % 4) == 2) | |
| 82 + ny += nh; | |
| 83 + else if((i % 4) == 3) { | |
| 84 + if(s) | |
| 85 + nx += nw; | |
| 86 + else | |
| 87 + nx -= nw; | |
| 88 + } | |
| 89 + if(i == 0) | |
| 90 + { | |
| 91 + if(n != 1) | |
| 92 + nw = mon->ww * mon->mfact; | |
| 93 + ny = mon->wy; | |
| 94 + } | |
| 95 + else if(i == 1) | |
| 96 + nw = mon->ww - nw; | |
| 97 + i++; | |
| 98 + } | |
| 99 + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False… | |
| 100 + } | |
| 101 +} | |
| 102 + | |
| 103 +void | |
| 104 +dwindle(Monitor *mon) { | |
| 105 + fibonacci(mon, 1); | |
| 106 +} | |
| 107 + | |
| 108 +void | |
| 109 +spiral(Monitor *mon) { | |
| 110 + fibonacci(mon, 0); | |
| 111 +} | |
| 112 -- | |
| 113 2.20.1 | |
| 114 |