dwm-fibonacci-5.8.2.diff (1587B)
1 diff --git a/config.def.h b/config.def.h 2 index cca37df..91b91aa 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -29,1 +29,2 @@ 6 +#include "fibonacci.c" 7 static const Layout layouts[] = { 8 @@ -34,3 +35,5 @@ 9 + { "[@]", spiral }, 10 + { "[\\]", dwindle }, 11 }; 12 13 /* key definitions */ 14 diff --git a/fibonacci.c b/fibonacci.c 15 new file mode 100644 16 index 0000000..fce0a57 17 --- /dev/null 18 +++ b/fibonacci.c 19 @@ -0,0 +1,66 @@ 20 +void 21 +fibonacci(Monitor *mon, int s) { 22 + unsigned int i, n, nx, ny, nw, nh; 23 + Client *c; 24 + 25 + for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); 26 + if(n == 0) 27 + return; 28 + 29 + nx = mon->wx; 30 + ny = 0; 31 + nw = mon->ww; 32 + nh = mon->wh; 33 + 34 + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { 35 + if((i % 2 && nh / 2 > 2 * c->bw) 36 + || (!(i % 2) && nw / 2 > 2 * c->bw)) { 37 + if(i < n - 1) { 38 + if(i % 2) 39 + nh /= 2; 40 + else 41 + nw /= 2; 42 + if((i % 4) == 2 && !s) 43 + nx += nw; 44 + else if((i % 4) == 3 && !s) 45 + ny += nh; 46 + } 47 + if((i % 4) == 0) { 48 + if(s) 49 + ny += nh; 50 + else 51 + ny -= nh; 52 + } 53 + else if((i % 4) == 1) 54 + nx += nw; 55 + else if((i % 4) == 2) 56 + ny += nh; 57 + else if((i % 4) == 3) { 58 + if(s) 59 + nx += nw; 60 + else 61 + nx -= nw; 62 + } 63 + if(i == 0) 64 + { 65 + if(n != 1) 66 + nw = mon->ww * mon->mfact; 67 + ny = mon->wy; 68 + } 69 + else if(i == 1) 70 + nw = mon->ww - nw; 71 + i++; 72 + } 73 + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); 74 + } 75 +} 76 + 77 +void 78 +dwindle(Monitor *mon) { 79 + fibonacci(mon, 1); 80 +} 81 + 82 +void 83 +spiral(Monitor *mon) { 84 + fibonacci(mon, 0); 85 +}