From ceff1487da208a141f8416b6b314cc38a5a860b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sat, 22 Jan 2011 16:09:11 -0200 Subject: [PATCH] Round up as well if needed (thanks Merovius). --- src/layout.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/layout.c b/src/layout.c index 9af1ffd9..c8a21bff 100644 --- a/src/layout.c +++ b/src/layout.c @@ -713,9 +713,10 @@ void render_workspace(xcb_connection_t *conn, Output *output, Workspace *r_ws) { /* Correct rounding errors */ int error = r_ws->rect.width - total_col_width, error_index = r_ws->cols - 1; + int signal = error < 0 ? 1 : -1; while (error) { - ++col_width[error_index]; - --error; + col_width[error_index] -= signal; + error += signal; error_index = error_index == 0 ? r_ws->cols - 1 : error_index - 1; } @@ -732,9 +733,10 @@ void render_workspace(xcb_connection_t *conn, Output *output, Workspace *r_ws) { /* Correct rounding errors */ error = workspace_height(r_ws) - total_row_height; error_index = r_ws->rows - 1; + signal = error < 0 ? 1 : -1; while (error) { - ++row_height[error_index]; - --error; + row_height[error_index] -= signal; + error += signal; error_index = error_index == 0 ? r_ws->rows - 1 : error_index - 1; } -- 2.39.5