-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnbstack.c
46 lines (45 loc) · 1.06 KB
/
nbstack.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
static void
nbstack(Monitor *m) {
int x, y, h, w, mh, nm, nmax;
unsigned int i, n;
Client *c;
/* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "T%dT", m->nmasters[m->curtag]);
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
c = nexttiled(m->clients);
nmax = m->nmasters[m->curtag];
nm = nmax == 1 ? 1 : MIN(n / 2, nmax);
if(nm > n)
nm = n;
/* master */
if(nm > 0) {
mh = m->mfact * m->wh;
w = m->ww / nm;
if(w < bh)
w = m->ww;
x = m->wx;
for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
(n == nm ? m->wh : mh) - 2 * c->bw, False);
if(w != m->ww)
x = c->x + WIDTH(c);
}
n -= nm;
} else
mh = 0;
if(n == 0)
return;
/* tile stack */
x = m->wx;
y = m->wy + mh;
w = m->ww / n;
h = m->wh - mh;
if(w < bh)
w = m->ww;
for(i = 0; c; c = nexttiled(c->next), i++) {
resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
h - 2 * c->bw, False);
if(w != m->ww)
x = c->x + WIDTH(c);
}
}