aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Pedro CĂ´rte-Real <pedro@pedrocr.net>2019-07-28 11:17:33 +0100
committerLibravatar Drew DeVault <sir@cmpwn.com>2020-01-01 10:14:29 -0700
commit800834476200298535f4ac1be8abe58fc501cb04 (patch)
tree2f5d8e3f71d090b7357d0adc376a401677ed9273 /include
parentUpdate wlroots version (diff)
downloadsway-800834476200298535f4ac1be8abe58fc501cb04.tar.gz
sway-800834476200298535f4ac1be8abe58fc501cb04.tar.zst
sway-800834476200298535f4ac1be8abe58fc501cb04.zip
Avoid numerical instability in resize
Because the layout code rounds down the dimensions of the windows resizing would often be off by one pixel. The width/height fraction would not exactly reflect the final computed width and so the resize code would end up calculating things wrong. To fix this first snap the container size fractions to the pixel grid and only then do the resize. Also use round() instead of floor() during layout to avoid a slightly too small width. This applies in two cases: 1. For the container we are actually resizing using floor() might result in being 1px too small. 2. For the other containers it might result in resizing them down by 1px and then if the container being resized is the last all those extra pixels would make the resize too large. Fixes #4391
Diffstat (limited to 'include')
-rw-r--r--include/sway/tree/container.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 099a8089..62c6556b 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -92,6 +92,11 @@ struct sway_container {
92 double width_fraction; 92 double width_fraction;
93 double height_fraction; 93 double height_fraction;
94 94
95 // The share of space of the parent container that all children occupy
96 // Used for doing the resize calculations
97 double child_total_width;
98 double child_total_height;
99
95 // These are in layout coordinates. 100 // These are in layout coordinates.
96 double content_x, content_y; 101 double content_x, content_y;
97 int content_width, content_height; 102 int content_width, content_height;