Mercurial > hg > index.fcgi > dwm > dwm-3.6.1-12pba
changeset 5:e060ab82b136
gapless grid
author | paulo@thepaulopc |
---|---|
date | Wed, 27 Jan 2010 23:28:29 -0800 |
parents | a54de16f8277 |
children | 0968b3739b8d |
files | layout.c |
diffstat | 1 files changed, 25 insertions(+), 22 deletions(-) [+] |
line diff
1.1 --- a/layout.c Fri Apr 24 01:34:17 2009 -0700 1.2 +++ b/layout.c Wed Jan 27 23:28:29 2010 -0800 1.3 @@ -222,43 +222,46 @@ 1.4 1.5 static void 1.6 grid(void) { 1.7 - unsigned int i, n, nx, ny, nw, nh, aw, ah, tw, th, cols, rows; 1.8 + unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch; 1.9 Client *c; 1.10 1.11 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 1.12 n++; 1.13 + if(n == 0) 1.14 + return; 1.15 1.16 - for(rows = 0; rows <= n/2; rows++) 1.17 - if(rows*rows >= n) 1.18 + /* grid dimensions */ 1.19 + for(cols = 0; cols <= n/2; cols++) 1.20 + if(cols*cols >= n) 1.21 break; 1.22 - cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; 1.23 + if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ 1.24 + cols = 2; 1.25 + rows = n/cols; 1.26 1.27 - th = wah / (rows ? rows : 1); 1.28 - tw = waw / (cols ? cols : 1); 1.29 - nw = tw - 2 * BORDERPX; 1.30 - nh = th - 2 * BORDERPX; 1.31 - 1.32 + /* window geometries */ 1.33 + cw = cols ? waw / cols : waw; 1.34 + cn = 0; /* current column number */ 1.35 + rn = 0; /* current row number */ 1.36 for(i = 0, c = clients; c; c = c->next) 1.37 if(isvisible(c)) { 1.38 - if(c->isbanned) 1.39 - XMoveWindow(dpy, c->win, c->x, c->y); 1.40 - c->isbanned = False; 1.41 - if(c->isversatile) 1.42 - continue; 1.43 - c->ismax = False; 1.44 - nx = (i / rows) * tw; 1.45 - ny = (i % rows) * th + (TOPBAR ? dc.h : 0); 1.46 - /* adjust height and width of last row's and last column's windows */ 1.47 - ah = ((i + 1) % rows == 0) ? wah - th * rows : 0; 1.48 - aw = (i >= rows * (cols - 1)) ? waw - tw * cols : 0; 1.49 - resize(c, nx, ny, nw + aw, nh + ah, False); 1.50 + if(i/rows + 1 > cols - n%cols) 1.51 + rows = n/cols + 1; 1.52 + ch = rows ? wah / rows : wah; 1.53 + cx = cn*cw; 1.54 + cy = (TOPBAR ? dc.h : 0) + rn*ch; 1.55 + resize(c, cx, cy, cw - 2 * BORDERPX, ch - 2 * BORDERPX, False); 1.56 + rn++; 1.57 + if(rn >= rows) { 1.58 + rn = 0; 1.59 + cn++; 1.60 + } 1.61 i++; 1.62 } 1.63 else { 1.64 c->isbanned = True; 1.65 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 1.66 } 1.67 - 1.68 + 1.69 if(!sel || !isvisible(sel)) { 1.70 for(c = stack; c && !isvisible(c); c = c->snext); 1.71 focus(c);