From d0233af3b39475b47be4248846536811ddca2624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20C=C3=B4rte-Real?= Date: Sat, 6 Jul 2019 11:57:32 +0100 Subject: Rework gaps code to be simpler and correct Instead of tracking gaps per child apply gaps in two logical places: 1. In tiled containers use the layout code to add the gaps between windows. This is much simpler and guarantees that the sizing of children is correct. 2. In the workspace itself apply all the gaps around the edge. Here we're in the correct position to size inner and outer gaps correctly and decide on smart gaps in a single location. Fixes #4296 --- sway/tree/workspace.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'sway/tree/workspace.c') diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 914b6a9d..accdf6e3 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -700,28 +700,7 @@ void workspace_insert_tiling(struct sway_workspace *workspace, node_set_dirty(&con->node); } -void workspace_remove_gaps(struct sway_workspace *ws) { - if (ws->current_gaps.top == 0 && ws->current_gaps.right == 0 && - ws->current_gaps.bottom == 0 && ws->current_gaps.left == 0) { - return; - } - - ws->width += ws->current_gaps.left + ws->current_gaps.right; - ws->height += ws->current_gaps.top + ws->current_gaps.bottom; - ws->x -= ws->current_gaps.left; - ws->y -= ws->current_gaps.top; - - ws->current_gaps.top = 0; - ws->current_gaps.right = 0; - ws->current_gaps.bottom = 0; - ws->current_gaps.left = 0; -} - void workspace_add_gaps(struct sway_workspace *ws) { - if (ws->current_gaps.top > 0 || ws->current_gaps.right > 0 || - ws->current_gaps.bottom > 0 || ws->current_gaps.left > 0) { - return; - } if (config->smart_gaps) { struct sway_seat *seat = input_manager_get_default_seat(); struct sway_container *focus = @@ -730,20 +709,19 @@ void workspace_add_gaps(struct sway_workspace *ws) { focus = seat_get_focus_inactive_view(seat, &focus->node); } if (focus && focus->view && view_is_only_visible(focus->view)) { + ws->current_gaps.top = 0; + ws->current_gaps.right = 0; + ws->current_gaps.bottom = 0; + ws->current_gaps.left = 0; return; } } ws->current_gaps = ws->gaps_outer; - if (ws->layout == L_TABBED || ws->layout == L_STACKED) { - // We have to add inner gaps for this, because children of tabbed and - // stacked containers don't apply their own gaps - they assume the - // tabbed/stacked container is using gaps. - ws->current_gaps.top += ws->gaps_inner; - ws->current_gaps.right += ws->gaps_inner; - ws->current_gaps.bottom += ws->gaps_inner; - ws->current_gaps.left += ws->gaps_inner; - } + ws->current_gaps.top += ws->gaps_inner; + ws->current_gaps.right += ws->gaps_inner; + ws->current_gaps.bottom += ws->gaps_inner; + ws->current_gaps.left += ws->gaps_inner; ws->x += ws->current_gaps.left; ws->y += ws->current_gaps.top; -- cgit v1.2.3