-
Notifications
You must be signed in to change notification settings - Fork 0
/
dwm-fibonacci-6.2.diff
93 lines (92 loc) · 2.32 KB
/
dwm-fibonacci-6.2.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
diff -upN a/config.def.h b/config.def.h
--- a/config.def.h 2019-05-28 13:43:00.326646120 +0200
+++ b/config.def.h 2019-05-28 21:17:55.213171996 +0200
@@ -36,8 +36,11 @@ static const float mfact = 0.55; /*
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+#include "fibonacci.c"
static const Layout layouts[] = {
/* symbol arrange function */
+ { "[@]", spiral },
+ { "[\\]", dwindle },
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
diff -upN a/fibonacci.c b/fibonacci.c
--- a/fibonacci.c 1970-01-01 01:00:00.000000000 +0100
+++ b/fibonacci.c 2019-05-28 21:07:51.119850125 +0200
@@ -0,0 +1,74 @@
+static void
+fibonacci(Monitor *m, int s)
+{
+ unsigned int i, n;
+ int nx, ny, nw, nh;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+ if (n == 1) {
+ c = nexttiled(m->clients);
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ return;
+ }
+
+ nx = m->wx + m->gappx;
+ ny = m->gappx;
+ nw = m->ww - 2*m->gappx;
+ nh = m->wh - 2*m->gappx;
+
+ for (i = 0, c = nexttiled(m->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 = (nh - m->gappx) / 2;
+ else
+ nw = (nw - m->gappx) / 2;
+
+ if ((i % 4) == 2 && !s)
+ nx += nw + m->gappx;
+ else if ((i % 4) == 3 && !s)
+ ny += nh + m->gappx;
+ }
+ if ((i % 4) == 0) {
+ if (s)
+ ny += nh + m->gappx;
+ else
+ ny -= nh + m->gappx;
+ }
+ else if ((i % 4) == 1)
+ nx += nw + m->gappx;
+ else if ((i % 4) == 2)
+ ny += nh + m->gappx;
+ else if ((i % 4) == 3) {
+ if (s)
+ nx += nw + m->gappx;
+ else
+ nx -= nw + m->gappx;
+ }
+ if (i == 0) {
+ if (n != 1)
+ nw = (m->ww - 2*m->gappx - m->gappx) * m->mfact;
+ ny = m->wy + m->gappx;
+ }
+ else if (i == 1)
+ nw = m->ww - nw - m->gappx - 2*m->gappx;
+ i++;
+ }
+
+ resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
+ }
+}
+
+void
+dwindle(Monitor *mon) {
+ fibonacci(mon, 1);
+}
+
+void
+spiral(Monitor *mon) {
+ fibonacci(mon, 0);
+}