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