sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit 95c444de337fcf39d16cc4d9b26842177f24256a
parent 99192a92f942f120f8cd0c6037c613325677a332
Author: Pedro Côrte-Real <pedro@pedrocr.net>
Date:   Sat,  6 Jul 2019 12:45:32 +0100

Sanity check gaps on the outside of the workspace

Avoid gaps that are too large around the workspace that you end up
without any usable space for children.

Fixes #4308

Diffstat:
Msway/tree/workspace.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c @@ -706,6 +706,25 @@ void workspace_add_gaps(struct sway_workspace *ws) { ws->current_gaps.bottom = fmax(0, ws->current_gaps.bottom + ws->gaps_inner); ws->current_gaps.left = fmax(0, ws->current_gaps.left + ws->gaps_inner); + // Now that we have the total gaps calculated we may need to clamp them in + // case they've made the available area too small + if (ws->width - ws->current_gaps.left - ws->current_gaps.right < MIN_SANE_W + && ws->current_gaps.left + ws->current_gaps.right > 0) { + int total_gap = fmax(0, ws->width - MIN_SANE_W); + double left_gap_frac = ((double)ws->current_gaps.left / + ((double)ws->current_gaps.left + (double)ws->current_gaps.right)); + ws->current_gaps.left = left_gap_frac * total_gap; + ws->current_gaps.right = total_gap - ws->current_gaps.left; + } + if (ws->height - ws->current_gaps.top - ws->current_gaps.bottom < MIN_SANE_H + && ws->current_gaps.top + ws->current_gaps.bottom > 0) { + int total_gap = fmax(0, ws->height - MIN_SANE_H); + double top_gap_frac = ((double) ws->current_gaps.top / + ((double)ws->current_gaps.top + (double)ws->current_gaps.bottom)); + ws->current_gaps.top = top_gap_frac * total_gap; + ws->current_gaps.bottom = total_gap - ws->current_gaps.top; + } + ws->x += ws->current_gaps.left; ws->y += ws->current_gaps.top; ws->width -= ws->current_gaps.left + ws->current_gaps.right;