diff options
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index aca35529..d6819c61 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -706,6 +706,25 @@ void workspace_add_gaps(struct sway_workspace *ws) { | |||
706 | ws->current_gaps.bottom = fmax(0, ws->current_gaps.bottom + ws->gaps_inner); | 706 | ws->current_gaps.bottom = fmax(0, ws->current_gaps.bottom + ws->gaps_inner); |
707 | ws->current_gaps.left = fmax(0, ws->current_gaps.left + ws->gaps_inner); | 707 | ws->current_gaps.left = fmax(0, ws->current_gaps.left + ws->gaps_inner); |
708 | 708 | ||
709 | // Now that we have the total gaps calculated we may need to clamp them in | ||
710 | // case they've made the available area too small | ||
711 | if (ws->width - ws->current_gaps.left - ws->current_gaps.right < MIN_SANE_W | ||
712 | && ws->current_gaps.left + ws->current_gaps.right > 0) { | ||
713 | int total_gap = fmax(0, ws->width - MIN_SANE_W); | ||
714 | double left_gap_frac = ((double)ws->current_gaps.left / | ||
715 | ((double)ws->current_gaps.left + (double)ws->current_gaps.right)); | ||
716 | ws->current_gaps.left = left_gap_frac * total_gap; | ||
717 | ws->current_gaps.right = total_gap - ws->current_gaps.left; | ||
718 | } | ||
719 | if (ws->height - ws->current_gaps.top - ws->current_gaps.bottom < MIN_SANE_H | ||
720 | && ws->current_gaps.top + ws->current_gaps.bottom > 0) { | ||
721 | int total_gap = fmax(0, ws->height - MIN_SANE_H); | ||
722 | double top_gap_frac = ((double) ws->current_gaps.top / | ||
723 | ((double)ws->current_gaps.top + (double)ws->current_gaps.bottom)); | ||
724 | ws->current_gaps.top = top_gap_frac * total_gap; | ||
725 | ws->current_gaps.bottom = total_gap - ws->current_gaps.top; | ||
726 | } | ||
727 | |||
709 | ws->x += ws->current_gaps.left; | 728 | ws->x += ws->current_gaps.left; |
710 | ws->y += ws->current_gaps.top; | 729 | ws->y += ws->current_gaps.top; |
711 | ws->width -= ws->current_gaps.left + ws->current_gaps.right; | 730 | ws->width -= ws->current_gaps.left + ws->current_gaps.right; |