author | Stiletto <blasux@blasux.ru> |
Sun, 12 May 2013 19:15:15 +0400 | |
branch | stil |
changeset 1538 | 6718f0ba24fd |
parent 1534 | ff21639cb978 |
permissions | -rw-r--r-- |
1534
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
1 |
void |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
2 |
fibonacci(Monitor *mon, int s) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
3 |
unsigned int i, n, nx, ny, nw, nh; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
4 |
Client *c; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
5 |
|
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
6 |
for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
7 |
if(n == 0) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
8 |
return; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
9 |
|
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
10 |
nx = mon->wx; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
11 |
ny = 0; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
12 |
nw = mon->ww; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
13 |
nh = mon->wh; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
14 |
|
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
15 |
for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
16 |
if((i % 2 && nh / 2 > 2 * c->bw) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
17 |
|| (!(i % 2) && nw / 2 > 2 * c->bw)) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
18 |
if(i < n - 1) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
19 |
if(i % 2) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
20 |
nh /= 2; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
21 |
else |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
22 |
nw /= 2; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
23 |
if((i % 4) == 2 && !s) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
24 |
nx += nw; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
25 |
else if((i % 4) == 3 && !s) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
26 |
ny += nh; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
27 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
28 |
if((i % 4) == 0) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
29 |
if(s) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
30 |
ny += nh; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
31 |
else |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
32 |
ny -= nh; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
33 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
34 |
else if((i % 4) == 1) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
35 |
nx += nw; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
36 |
else if((i % 4) == 2) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
37 |
ny += nh; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
38 |
else if((i % 4) == 3) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
39 |
if(s) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
40 |
nx += nw; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
41 |
else |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
42 |
nx -= nw; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
43 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
44 |
if(i == 0) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
45 |
{ |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
46 |
if(n != 1) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
47 |
nw = mon->ww * selmon->mfacts[selmon->curtag]; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
48 |
ny = mon->wy; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
49 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
50 |
else if(i == 1) |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
51 |
nw = mon->ww - nw; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
52 |
i++; |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
53 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
54 |
resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
55 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
56 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
57 |
|
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
58 |
void |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
59 |
dwindle(Monitor *mon) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
60 |
fibonacci(mon, 1); |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
61 |
} |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
62 |
|
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
63 |
void |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
64 |
spiral(Monitor *mon) { |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
65 |
fibonacci(mon, 0); |
ff21639cb978
Pango markup support and fibonacci layout.
Stiletto <blasux@blasux.ru>
parents:
diff
changeset
|
66 |
} |