precalculate_sizes: round sizes instead of flooring them

This will lead to more accurate and consistent container sizes.

Needed to fix the failing test of #3240.
This commit is contained in:
Orestis Floros 2018-08-23 21:57:21 +03:00
parent db294f4505
commit 7b9318a541
No known key found for this signature in database
GPG Key ID: E9AD9F32E401E38F
1 changed files with 1 additions and 1 deletions

View 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; int total = con_orientation(con) == HORIZ ? p->rect.width : p->rect.height;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) { TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
double percentage = child->percent > 0.0 ? child->percent : 1.0 / p->children; 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 || assert(assigned == total ||
(assigned > total && assigned - total <= p->children * 2) || (assigned > total && assigned - total <= p->children * 2) ||