vt: respect relative position mode when clamping cursor
[dvtm.git] / tstack.c
blob19c64cbd4fdba28011c47cf8b2e854bc4def6ef3
1 void
2 tstack(void) {
3 unsigned int i, m, n, nx, ny, nw, nh, mh, tw;
4 Client *c;
6 for(n = 0, m = 0, c = clients; c; c = c->next, n++)
7 if(c->minimized)
8 m++;
10 /* relative height */
11 mh = (wah - m) * (n == 1 || n - 1 == m ? 1 : screen.mfact);
13 /* true if there are at least 2 non minimized clients */
14 if(n - 1 > m)
15 tw = waw / (n - m - 1);
17 nx = wax, nw = waw;
18 for(i = 0, c = clients; c; c = c->next, i++){
19 if(i == 0){ /* master */
20 ny = way + wah - mh;
21 nh = mh;
23 else { /* tile window */
24 if(i == 1){
25 nx = wax;
26 ny = way + m;
27 nh = wah - mh - ny + way;
29 if(i == n - m - 1){ /* last not minimized client */
30 nw = (wax + waw) - nx;
32 else if(i == n - m) { /* first minimized client */
33 nx = wax;
34 --ny;
35 nh = 1;
36 nw = waw;
38 else if(c->minimized) { /* minimized window */
39 --ny;
40 nh = 1;
41 nw = waw;
43 else /* normal non minimized tile window */
44 nw = tw;
46 if(i > 1 && !c->minimized){
47 mvvline(ny, nx, ACS_VLINE, nh);
48 mvaddch(ny, nx, ACS_TTEE);
49 ++nx, --nw;
53 resize(c,nx,ny,nw,nh);
55 if(n > 1 && i < n - m - 1)
56 nx += nw;