fibonacci.c (1410B)
1 void 2 fibonacci(Monitor *mon, int s) { 3 unsigned int i, n, nx, ny, nw, nh, oe, ie; 4 int oh, ov, ih, iv; 5 Client *c; 6 7 oe = ie = enablegaps; 8 9 for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); 10 if(n == 0) { 11 return; 12 } 13 if (smartgaps && n == 1) { 14 oe = 0; 15 } 16 17 oh = mon->gappoh*oe; 18 ov = mon->gappov*oe; 19 ih = mon->gappih*ie; 20 iv = mon->gappiv*ie; 21 22 nx = mon->wx + ov; 23 ny = oh; 24 nw = mon->ww - 2*ov; 25 nh = mon->wh - 2*oh; 26 27 for (i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { 28 if ((i % 2 && nh / 2 > 2*c->bw) 29 || (!(i % 2) && nw / 2 > 2*c->bw)) { 30 if (i < n - 1) { 31 if (i % 2) 32 nh = (nh - ih) / 2; 33 else 34 nw = (nw - iv) / 2; 35 36 if ((i % 4) == 2 && !s) 37 nx += nw + iv; 38 else if ((i % 4) == 3 && !s) 39 ny += nh + ih; 40 } 41 if ((i % 4) == 0) { 42 if (s) 43 ny += nh + ih; 44 else 45 ny -= nh + ih; 46 } 47 else if ((i % 4) == 1) 48 nx += nw + iv; 49 else if ((i % 4) == 2) 50 ny += nh + ih; 51 else if ((i % 4) == 3) { 52 if (s) 53 nx += nw + iv; 54 else 55 nx -= nw + iv; 56 } 57 if (i == 0) { 58 if (n != 1) 59 nw = (mon->ww - 2*ov - iv) * mon->mfact; 60 ny = mon->wy + oh; 61 } 62 else if (i == 1) 63 nw = mon->ww - nw - iv - 2*ov; 64 i++; 65 } 66 67 resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); 68 } 69 } 70 71 void 72 dwindle(Monitor *mon) { 73 fibonacci(mon, 1); 74 } 75 76 void 77 spiral(Monitor *mon) { 78 fibonacci(mon, 0); 79 }