From: Michael Stapelberg Date: Sat, 12 Sep 2009 17:58:39 +0000 (+0200) Subject: Bugfix: Re-distribute free space when closing rows which were horizontally resized X-Git-Tag: 3.d~92 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=30ad7e93e7338f86821b59438e072a7abf5db32d;p=i3%2Fi3 Bugfix: Re-distribute free space when closing rows which were horizontally resized --- 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