From 485555ef72dc99cff68cab78cc0c9da914702618 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sat, 22 Jan 2011 15:54:49 -0200 Subject: [PATCH] Round up as well if needed (thanks Merovius). --- src/render.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/render.c b/src/render.c index 9d214ce6..b79d463f 100644 --- a/src/render.c +++ b/src/render.c @@ -118,10 +118,11 @@ void render_con(Con *con, bool render_fullscreen) { double percentage = child->percent > 0.0 ? child->percent : 1.0 / children; assigned += sizes[i++] = percentage * total; } - while (assigned < total) { + int signal = assigned < total ? 1 : -1; + while (assigned != total) { for (i = 0; i < children && assigned < total; ++i) { - ++sizes[i]; - ++assigned; + sizes[i] += signal; + assigned += signal; } } } -- 2.39.5