diff options
Diffstat (limited to 'sway/commands/resize.c')
-rw-r--r-- | sway/commands/resize.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 0c9af12d..7ff4ef7b 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -172,9 +172,19 @@ void container_resize_tiled(struct sway_container *con, | |||
172 | if (prev && prev->width - sibling_amount < MIN_SANE_W) { | 172 | if (prev && prev->width - sibling_amount < MIN_SANE_W) { |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | if (con->child_total_width <= 0) { | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | // We're going to resize so snap all the width fractions to full pixels | ||
180 | // to avoid rounding issues | ||
181 | list_t *siblings = container_get_siblings(con); | ||
182 | for (int i = 0; i < siblings->length; ++i) { | ||
183 | struct sway_container *con = siblings->items[i]; | ||
184 | con->width_fraction = con->width / con->child_total_width; | ||
185 | } | ||
175 | 186 | ||
176 | double amount_fraction = | 187 | double amount_fraction = (double)amount / con->child_total_width; |
177 | ((double)amount / con->width) * con->width_fraction; | ||
178 | double sibling_amount_fraction = | 188 | double sibling_amount_fraction = |
179 | prev ? amount_fraction / 2.0 : amount_fraction; | 189 | prev ? amount_fraction / 2.0 : amount_fraction; |
180 | 190 | ||
@@ -193,9 +203,19 @@ void container_resize_tiled(struct sway_container *con, | |||
193 | if (prev && prev->height - sibling_amount < MIN_SANE_H) { | 203 | if (prev && prev->height - sibling_amount < MIN_SANE_H) { |
194 | return; | 204 | return; |
195 | } | 205 | } |
206 | if (con->child_total_height <= 0) { | ||
207 | return; | ||
208 | } | ||
209 | |||
210 | // We're going to resize so snap all the height fractions to full pixels | ||
211 | // to avoid rounding issues | ||
212 | list_t *siblings = container_get_siblings(con); | ||
213 | for (int i = 0; i < siblings->length; ++i) { | ||
214 | struct sway_container *con = siblings->items[i]; | ||
215 | con->height_fraction = con->height / con->child_total_height; | ||
216 | } | ||
196 | 217 | ||
197 | double amount_fraction = | 218 | double amount_fraction = (double)amount / con->child_total_height; |
198 | ((double)amount / con->height) * con->height_fraction; | ||
199 | double sibling_amount_fraction = | 219 | double sibling_amount_fraction = |
200 | prev ? amount_fraction / 2.0 : amount_fraction; | 220 | prev ? amount_fraction / 2.0 : amount_fraction; |
201 | 221 | ||