]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Re-distribute free space when closing rows which were horizontally resized
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 12 Sep 2009 17:58:39 +0000 (19:58 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 12 Sep 2009 17:58:39 +0000 (19:58 +0200)
src/table.c

index dab4b9ac1665f75c0be578c81d72a0c8bdc6cac7..43df8d3df8b67bd67f100a1e3581b2af5323a468 100644 (file)
@@ -198,11 +198,29 @@ static void shrink_table_cols(Workspace *workspace) {
  *
  */
 static void shrink_table_rows(Workspace *workspace) {
+        float free_space = workspace->height_factor[workspace->rows-1];
+
         workspace->rows--;
         for (int cols = 0; cols < workspace->cols; cols++)
                 workspace->table[cols] = realloc(workspace->table[cols], sizeof(Container*) * workspace->rows);
-}
 
+        /* Shrink the height_factor array */
+        workspace->height_factor = realloc(workspace->height_factor, sizeof(float) * workspace->rows);
+
+        /* Distribute the free space */
+        if (free_space == 0)
+                return;
+
+        for (int rows = (workspace->rows-1); rows >= 0; rows--) {
+                if (workspace->height_factor[rows] == 0)
+                        continue;
+
+                LOG("Added free space (%f) to %d (had %f)\n", free_space, rows,
+                                workspace->height_factor[rows]);
+                workspace->height_factor[rows] += free_space;
+                break;
+        }
+}
 
 /*
  * Performs simple bounds checking for the given column/row