From: Ryan McBride Date: Tue, 3 Feb 2009 14:49:40 +0000 (+0000) Subject: Better, hopefully math-exception-free logic for multi-column stacker, and X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=3c99b00a532db0b6276b46b91efe48033fbdbfbf;p=spectrwm.git Better, hopefully math-exception-free logic for multi-column stacker, and fix off-by-two error in stack width calculations. --- diff --git a/scrotwm.c b/scrotwm.c index 6f891fe..3fb090f 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -1390,9 +1390,9 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip) continue; if (split && i == split) { - colno = (winno - split) / s; - if (stacks == 1) - colno += (winno - split) % s; + colno = (winno - mwin) / stacks; + if (s <= (winno - mwin) % stacks) + colno++; split = split + colno; hrh = (r_g.h / colno); extra = r_g.h - (colno * hrh); @@ -1400,7 +1400,11 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip) win_g.x = r_g.x; else win_g.x += win_g.w + 2; - win_g.w = (r_g.w - (msize + 2) - (stacks * 2)) / stacks; + win_g.w = (((r_g.w - (msize + 2)) - + ((stacks - 1) * 2)) / stacks); + if (s == 1) + win_g.w += (((r_g.w - (msize + 2)) - + ((stacks - 1) * 2)) % stacks); s--; j = 0; }