add new layouts
[azarus-dwm.git] / fibonacci.c
blobfce0a577be59fdae442bf9d84adfe3f0800ac43b
1 void
2 fibonacci(Monitor *mon, int s) {
3 unsigned int i, n, nx, ny, nw, nh;
4 Client *c;
6 for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
7 if(n == 0)
8 return;
10 nx = mon->wx;
11 ny = 0;
12 nw = mon->ww;
13 nh = mon->wh;
15 for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
16 if((i % 2 && nh / 2 > 2 * c->bw)
17 || (!(i % 2) && nw / 2 > 2 * c->bw)) {
18 if(i < n - 1) {
19 if(i % 2)
20 nh /= 2;
21 else
22 nw /= 2;
23 if((i % 4) == 2 && !s)
24 nx += nw;
25 else if((i % 4) == 3 && !s)
26 ny += nh;
28 if((i % 4) == 0) {
29 if(s)
30 ny += nh;
31 else
32 ny -= nh;
34 else if((i % 4) == 1)
35 nx += nw;
36 else if((i % 4) == 2)
37 ny += nh;
38 else if((i % 4) == 3) {
39 if(s)
40 nx += nw;
41 else
42 nx -= nw;
44 if(i == 0)
46 if(n != 1)
47 nw = mon->ww * mon->mfact;
48 ny = mon->wy;
50 else if(i == 1)
51 nw = mon->ww - nw;
52 i++;
54 resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
58 void
59 dwindle(Monitor *mon) {
60 fibonacci(mon, 1);
63 void
64 spiral(Monitor *mon) {
65 fibonacci(mon, 0);