Make inner gaps apply evenly across all windows

To make sure inner gaps don't generate unequally sized windows always
apply a total of one inner gap to all children. Doing just this would
result in half-gaps around the workspace border so compensate for that
by adding gaps to the workspace.

Fixes #4296
This commit is contained in:
Pedro Côrte-Real 2019-06-30 23:42:28 +01:00
parent f5d1c27226
commit 5c0396b3f1
2 changed files with 19 additions and 4 deletions

View file

@ -1226,10 +1226,13 @@ void container_add_gaps(struct sway_container *c) {
} }
} }
c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0; int gaps1 = ws->gaps_inner / 2;
c->current_gaps.right = ws->gaps_inner; int gaps2 = ws->gaps_inner - gaps1;
c->current_gaps.bottom = ws->gaps_inner;
c->current_gaps.left = c->x == ws->x ? ws->gaps_inner : 0; 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->x += c->current_gaps.left;
c->y += c->current_gaps.top; c->y += c->current_gaps.top;

View file

@ -743,6 +743,18 @@ void workspace_add_gaps(struct sway_workspace *ws) {
ws->current_gaps.right += ws->gaps_inner; ws->current_gaps.right += ws->gaps_inner;
ws->current_gaps.bottom += ws->gaps_inner; ws->current_gaps.bottom += ws->gaps_inner;
ws->current_gaps.left += 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; ws->x += ws->current_gaps.left;