Skip to content

Commit

Permalink
Fix tiling issue described in Airblader#22
Browse files Browse the repository at this point in the history
Currently, containers only consider their neighbors and screen edges
If >2 containers are in a line, the outer containers adjust from outer gaps, but the middle containers know nothing of this and only consider the inner gaps
When the outer gaps differ substantially from the inner gaps, the outer containers are smaller as only they adjust for the larger outer gaps

With this change, the containers stop considering the edges, and instead the workspace as a whole is inset before any containers
The result is that many tiled containers have the same size, and the gaps overall work as the user might expect them to
  • Loading branch information
cameronleger committed Nov 10, 2018
1 parent 75db550 commit 07b51df
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,28 @@ void render_con(Con *con, bool render_fullscreen, bool already_inset) {
(render_fullscreen ? "fullscreen " : ""), con, con->name, con->layout,
params.children);

if (con->type == CT_WORKSPACE) {
gaps_t gaps = calculate_effective_gaps(con);
Rect inset = {
gaps.left,
gaps.top,
-(gaps.left + gaps.right),
-(gaps.top + gaps.bottom)
};
con->rect = rect_add(con->rect, inset);
params.rect = rect_add(params.rect, inset);
params.x += gaps.left;
params.y += gaps.top;
}

bool should_inset = should_inset_con(con, params.children);
if (!already_inset && should_inset) {
gaps_t gaps = calculate_effective_gaps(con);
Rect inset = (Rect){
has_adjacent_container(con, D_LEFT) ? gaps.inner : gaps.left,
has_adjacent_container(con, D_UP) ? gaps.inner : gaps.top,
has_adjacent_container(con, D_RIGHT) ? -gaps.inner : -gaps.right,
has_adjacent_container(con, D_DOWN) ? -gaps.inner : -gaps.bottom};
inset.width -= inset.x;
inset.height -= inset.y;
has_adjacent_container(con, D_LEFT) ? gaps.inner : 0,
has_adjacent_container(con, D_UP) ? gaps.inner : 0,
has_adjacent_container(con, D_RIGHT) ? -gaps.inner : 0,
has_adjacent_container(con, D_DOWN) ? -gaps.inner : 0};

if (!render_fullscreen) {
params.rect = rect_add(params.rect, inset);
Expand Down

0 comments on commit 07b51df

Please sign in to comment.