# HG changeset patch # User xav@nx7400.lan # Date 1192120963 -7200 # Node ID e88c8fdc5f5ee29b054f37c605fcab6ee9585bc8 # Parent b4c4c98205ccbfb5aeff32ba4947756dc3248989 Add fibonacci layouts. diff -r b4c4c98205cc -r e88c8fdc5f5e config.def.h --- a/config.def.h Wed Oct 10 18:51:03 2007 +0200 +++ b/config.def.h Thu Oct 11 18:42:43 2007 +0200 @@ -22,7 +22,8 @@ Rule rules[] = { }; /* layout(s) */ -#define ISTILE isarrange(tile) /* || isarrange() */ +#include "fibonacci.c" +#define ISTILE (isarrange(tile) || isarrange(spiral) || isarrange(dwindle)) #define MWFACT 0.6 /* master width factor [0.1 .. 0.9] */ #define RESIZEHINTS True /* False - respect size hints in tiled resizals */ #define SNAP 32 /* snap pixel */ @@ -30,6 +31,8 @@ Layout layouts[] = { /* symbol function */ { "[]=", tile }, /* first entry is default */ { "><>", floating }, + { "(@)", spiral }, /* fibonacci spiral */ + { "[\\]", dwindle }, /* fibonacci diagonal */ }; /* key definitions */ diff -r b4c4c98205cc -r e88c8fdc5f5e fibonacci.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fibonacci.c Thu Oct 11 18:42:43 2007 +0200 @@ -0,0 +1,64 @@ +/* See LICENSE file for copyright and license details. */ + +/* static */ + +static void +fibonacci(int shape) { + unsigned int i, n, nx, ny, nw, nh; + Client *c; + + nx = wax; + ny = 0; + nw = waw; + nh = wah; + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) + n++; + for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { + c->ismax = False; + if((i % 2 && nh / 2 > 2 * c->border) + || (!(i % 2) && nw / 2 > 2 * c->border)) + { + if(i < n - 1) { + if(i % 2) + nh /= 2; + else + nw /= 2; + if((i % 4) == 2 && !shape) + nx += nw; + else if((i % 4) == 3 && !shape) + ny += nh; + } + if((i % 4) == 0) { + if(shape) + 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(shape) + nx += nw; + else + nx -= nw; + } + if(i == 0) + ny = way; + } + resize(c, nx, ny, nw - 2 * c->border, nh - 2 * c->border, False); + } + focus(NULL); + restack(); +} + +static void +dwindle(void) { + fibonacci(1); +} + +static void +spiral(void) { + fibonacci(0); +}