diff options
author | Pedro CĂ´rte-Real <pedro@pedrocr.net> | 2019-07-06 12:13:05 +0100 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-07-15 23:46:27 -0400 |
commit | 44c2fafa4f561969c5987293863e9dfd63fc2ada (patch) | |
tree | 21c00c3790b825b6cab6ebd68061a4d98fc2c256 /sway/tree | |
parent | d0233af3b39475b47be4248846536811ddca2624 (diff) | |
download | sway-44c2fafa4f561969c5987293863e9dfd63fc2ada.tar.xz |
Sanity check gaps between tiled containers
When the gaps become too large for the space available gracefully
reduced them all the way to 0 if needed.
Fixes #4294
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/arrange.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index caafb1af..696d0e1f 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -68,7 +68,10 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) { } temp = temp->parent; } - double child_total_width = parent->width - inner_gap * (children->length - 1); + double total_gap = fmin(inner_gap * (children->length - 1), + fmax(0, parent->width - MIN_SANE_W * children->length)); + double child_total_width = parent->width - total_gap; + inner_gap = total_gap / (children->length - 1); // Resize windows sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); @@ -143,7 +146,10 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { } temp = temp->parent; } - double child_total_height = parent->height - inner_gap * (children->length - 1); + double total_gap = fmin(inner_gap * (children->length - 1), + fmax(0, parent->height - MIN_SANE_H * children->length)); + double child_total_height = parent->height - total_gap; + inner_gap = total_gap / (children->length - 1); // Resize windows sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); |