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/arrange.c | |
parent | Rework gaps code to be simpler and correct (diff) | |
download | sway-44c2fafa4f561969c5987293863e9dfd63fc2ada.tar.gz sway-44c2fafa4f561969c5987293863e9dfd63fc2ada.tar.zst sway-44c2fafa4f561969c5987293863e9dfd63fc2ada.zip |
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/arrange.c')
-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) { | |||
68 | } | 68 | } |
69 | temp = temp->parent; | 69 | temp = temp->parent; |
70 | } | 70 | } |
71 | double child_total_width = parent->width - inner_gap * (children->length - 1); | 71 | double total_gap = fmin(inner_gap * (children->length - 1), |
72 | fmax(0, parent->width - MIN_SANE_W * children->length)); | ||
73 | double child_total_width = parent->width - total_gap; | ||
74 | inner_gap = total_gap / (children->length - 1); | ||
72 | 75 | ||
73 | // Resize windows | 76 | // Resize windows |
74 | sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); | 77 | sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); |
@@ -143,7 +146,10 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { | |||
143 | } | 146 | } |
144 | temp = temp->parent; | 147 | temp = temp->parent; |
145 | } | 148 | } |
146 | double child_total_height = parent->height - inner_gap * (children->length - 1); | 149 | double total_gap = fmin(inner_gap * (children->length - 1), |
150 | fmax(0, parent->height - MIN_SANE_H * children->length)); | ||
151 | double child_total_height = parent->height - total_gap; | ||
152 | inner_gap = total_gap / (children->length - 1); | ||
147 | 153 | ||
148 | // Resize windows | 154 | // Resize windows |
149 | sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); | 155 | sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); |