-
Notifications
You must be signed in to change notification settings - Fork 0
/
bstack.c
58 lines (54 loc) · 1.12 KB
/
bstack.c
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
static void bstack(void)
{
unsigned int i, n, nx, ny, nw, nh, m, mw, mh, tw;
Client *c;
for (n = 0, c = nextvisible(clients); c; c = nextvisible(c->next))
if (!c->minimized)
n++;
m = MAX(1, MIN(n, screen.nmaster));
mh = n == m ? wah : screen.mfact * wah;
mw = waw / m;
tw = n == m ? 0 : waw / (n - m);
nx = wax;
ny = way;
for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next)) {
if (c->minimized)
continue;
if (i < m) { /* master */
if (i > 0) {
mvvline(ny, nx, ACS_VLINE, nh);
mvaddch(ny, nx, ACS_TTEE);
nx++;
}
nh = mh;
nw = (i < m - 1) ? mw : (wax + waw) - nx;
} else { /* tile window */
if (i == m) {
nx = wax;
ny += mh;
nh = (way + wah) - ny;
}
if (i > m) {
mvvline(ny, nx, ACS_VLINE, nh);
mvaddch(ny, nx, ACS_TTEE);
nx++;
}
nw = (i < n - 1) ? tw : (wax + waw) - nx;
}
resize(c, nx, ny, nw, nh);
nx += nw;
i++;
}
/* Fill in nmaster intersections */
if (n > m) {
nx = wax;
for (i = 0; i < m; i++) {
if (i > 0) {
mvaddch(ny, nx, ACS_PLUS);
nx++;
}
nw = (i < m - 1) ? mw : (wax + waw) - nx;
nx += nw;
}
}
}