aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-01-23 04:25:50 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-01-23 04:25:50 +0200
commit917f0225788b9fe50331f174ea219296620b2e9e (patch)
treecbbefbdfdc7a869db423cbca62f04151582ad9b2
parent011840f8c5933c34b709a37acd7f5031dae1f47e (diff)
do not create gaps on grid layout when client is floating
-rw-r--r--monsterwm.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/monsterwm.c b/monsterwm.c
index f89dbbf..77d1111 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -459,21 +459,16 @@ void grabkeys(void) {
/* arrange windows in a grid */
void grid(int hh, int cy) {
- /* num of windows, client x/y coords and width/height, columns/rows, current column/row num */
- int n = 0, cx, cw, ch, cols, rows, cn=0, rn=0, i=0;
+ int n = 0, cols = 0;
for (client *c = head; c; c=c->next) if (!c->istransient && !c->isfullscrn && !c->isfloating) ++n;
-
for (cols=0; cols <= n/2; cols++) if (cols*cols >= n) break; /* emulate square root */
if (n == 5) cols = 2;
- rows = n/cols;
- cw = cols ? ww/cols : ww;
+
+ int rows = n/cols, cw = (cols ? ww/cols : ww), cn = 0, rn = 0, i = 0;
for (client *c=head; c; c=c->next, i++) {
+ if (c->isfullscrn || c->istransient || c->isfloating) { i--; continue; }
if (i/rows + 1 > cols - n%cols) rows = n/cols + 1;
- ch = hh/rows;
- cx = cn*cw;
- cy = (TOP_PANEL && showpanel ? PANEL_HEIGHT : 0) + rn*ch;
- if (!c->isfullscrn && !c->istransient && !c->isfloating)
- XMoveResizeWindow(dis, c->win, cx, cy, cw - BORDER_WIDTH, ch - BORDER_WIDTH);
+ XMoveResizeWindow(dis, c->win, cn*cw, cy + rn*hh/rows, cw - BORDER_WIDTH, hh/rows - BORDER_WIDTH);
if (++rn >= rows) { rn = 0; cn++; }
}
}