]> git.sur5r.net Git - i3/i3/commitdiff
Round up as well if needed (thanks Merovius).
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Sat, 22 Jan 2011 18:09:11 +0000 (16:09 -0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 23 Jan 2011 12:22:11 +0000 (13:22 +0100)
src/layout.c

index 9af1ffd93aadfc390ef539d20f6dde91c73c5ad7..c8a21bff85d8dbd5d3f01e06020d18798558c741 100644 (file)
@@ -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;
         }