diff options
author | Pedro CĂ´rte-Real <pedro@pedrocr.net> | 2019-07-28 11:29:48 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-01-08 10:27:20 -0500 |
commit | 9ad22109bb9d819ddcb19718cbe7a95c1764a8d9 (patch) | |
tree | 9b7de0abdf1414d5910fe24f31aed4b1aabc5cea /sway/tree | |
parent | Avoid numerical instability in resize (diff) | |
download | sway-9ad22109bb9d819ddcb19718cbe7a95c1764a8d9.tar.gz sway-9ad22109bb9d819ddcb19718cbe7a95c1764a8d9.tar.zst sway-9ad22109bb9d819ddcb19718cbe7a95c1764a8d9.zip |
Make sure we don't calculate fractional pixel gaps
When gaps are resized for lack of space the calculation could result in
a gap size of non-integer pixels. This would result in containers
located at non-integer pixels which would be subtly broken.
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/arrange.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index e4f59110..bac9f2fa 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c | |||
@@ -71,7 +71,7 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) { | |||
71 | double total_gap = fmin(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)); | 72 | fmax(0, parent->width - MIN_SANE_W * children->length)); |
73 | double child_total_width = parent->width - total_gap; | 73 | double child_total_width = parent->width - total_gap; |
74 | inner_gap = total_gap / (children->length - 1); | 74 | inner_gap = floor(total_gap / (children->length - 1)); |
75 | 75 | ||
76 | // Resize windows | 76 | // Resize windows |
77 | sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); | 77 | sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); |
@@ -150,7 +150,7 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { | |||
150 | double total_gap = fmin(inner_gap * (children->length - 1), | 150 | double total_gap = fmin(inner_gap * (children->length - 1), |
151 | fmax(0, parent->height - MIN_SANE_H * children->length)); | 151 | fmax(0, parent->height - MIN_SANE_H * children->length)); |
152 | double child_total_height = parent->height - total_gap; | 152 | double child_total_height = parent->height - total_gap; |
153 | inner_gap = total_gap / (children->length - 1); | 153 | inner_gap = floor(total_gap / (children->length - 1)); |
154 | 154 | ||
155 | // Resize windows | 155 | // Resize windows |
156 | sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); | 156 | sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); |