]> git.sur5r.net Git - i3/i3/commitdiff
precalculate_sizes: round sizes instead of flooring them
authorOrestis Floros <orestisf1993@gmail.com>
Thu, 23 Aug 2018 18:57:21 +0000 (21:57 +0300)
committerOrestis Floros <orestisf1993@gmail.com>
Fri, 24 Aug 2018 01:12:14 +0000 (04:12 +0300)
This will lead to more accurate and consistent container sizes.

Needed to fix the failing test of #3240.

src/render.c

index 0125b89d683a42346edaa179e902edba3affb447..8699660edd470934fe19a62bab841e93cc6b35c0 100644 (file)
@@ -192,7 +192,7 @@ static int *precalculate_sizes(Con *con, render_params *p) {
         int total = con_orientation(con) == HORIZ ? p->rect.width : p->rect.height;
         TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
             double percentage = child->percent > 0.0 ? child->percent : 1.0 / p->children;
-            assigned += sizes[i++] = percentage * total;
+            assigned += sizes[i++] = lround(percentage * total);
         }
         assert(assigned == total ||
                (assigned > total && assigned - total <= p->children * 2) ||