diff -up -N dwm/config.def.h fibonacci/config.def.h --- dwm/config.def.h 2008-10-04 15:57:46.000000000 -0400 +++ fibonacci/config.def.h 2008-10-04 15:54:06.000000000 -0400 @@ -28,11 +28,14 @@ static Rule rules[] = { static float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static Bool resizehints = True; /* False means respect size hints in tiled resizals */ +#include "fibonacci.c" static Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[@]", spiral }, + { "[\\]", dwindle }, }; /* key definitions */ diff -up -N dwm/fibonacci.c fibonacci/fibonacci.c --- dwm/fibonacci.c 1969-12-31 19:00:00.000000000 -0500 +++ fibonacci/fibonacci.c 2008-10-04 15:54:06.000000000 -0400 @@ -0,0 +1,66 @@ +void +fibonacci(int s) { + unsigned int i, n, nx, ny, nw, nh; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + nx = wx; + ny = 0; + nw = ww; + nh = wh; + + for(i = 0, c = nexttiled(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 = ww * mfact; + ny = wy; + } + else if(i == 1) + nw = ww - nw; + i++; + } + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); + } +} + +void +dwindle(void) { + fibonacci(1); +} + +void +spiral(void) { + fibonacci(0); +}