diff --git a/sway/tree/container.c b/sway/tree/container.c index 9046ae27d..dd5b6d7bb 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1226,10 +1226,13 @@ void container_add_gaps(struct sway_container *c) { } } - c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0; - c->current_gaps.right = ws->gaps_inner; - c->current_gaps.bottom = ws->gaps_inner; - c->current_gaps.left = c->x == ws->x ? ws->gaps_inner : 0; + int gaps1 = ws->gaps_inner / 2; + int gaps2 = ws->gaps_inner - gaps1; + + c->current_gaps.top = gaps1; + c->current_gaps.bottom = gaps2; + c->current_gaps.left = gaps1; + c->current_gaps.right = gaps2; c->x += c->current_gaps.left; c->y += c->current_gaps.top; diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 914b6a9de..7d7422de5 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -743,6 +743,18 @@ void workspace_add_gaps(struct sway_workspace *ws) { ws->current_gaps.right += ws->gaps_inner; ws->current_gaps.bottom += ws->gaps_inner; ws->current_gaps.left += ws->gaps_inner; + } else { + // For tiled containers we need to add the half-gap all around the edge + // to match the half gaps that the children have all already added around + // themselves. We use the opposite gaps1/gaps2 order so that the sum adds + // up to the correct total gap size in all circumstances. + int gaps1 = ws->gaps_inner / 2; + int gaps2 = ws->gaps_inner - gaps1; + + ws->current_gaps.top += gaps2; + ws->current_gaps.bottom += gaps1; + ws->current_gaps.left += gaps2; + ws->current_gaps.right += gaps1; } ws->x += ws->current_gaps.left;