From 30ad7e93e7338f86821b59438e072a7abf5db32d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 12 Sep 2009 19:58:39 +0200 Subject: [PATCH] Bugfix: Re-distribute free space when closing rows which were horizontally resized --- src/table.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/table.c b/src/table.c index dab4b9ac..43df8d3d 100644 --- a/src/table.c +++ b/src/table.c @@ -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 -- 2.39.5