diff options
-rw-r--r-- | include/sway/commands.h | 2 | ||||
-rw-r--r-- | sway/commands/resize.c | 26 |
2 files changed, 15 insertions, 13 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 48228a98..ab2da1a9 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -95,7 +95,7 @@ struct cmd_results *add_color(const char *name, | |||
95 | /** | 95 | /** |
96 | * TODO: Move this function and its dependent functions to container.c. | 96 | * TODO: Move this function and its dependent functions to container.c. |
97 | */ | 97 | */ |
98 | bool container_resize_tiled(struct sway_container *parent, enum wlr_edges edge, | 98 | void container_resize_tiled(struct sway_container *parent, enum wlr_edges edge, |
99 | int amount); | 99 | int amount); |
100 | 100 | ||
101 | sway_cmd cmd_assign; | 101 | sway_cmd cmd_assign; |
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 1343b165..6de14ca3 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -179,11 +179,11 @@ static void container_recursive_resize(struct sway_container *container, | |||
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | static bool resize_tiled(struct sway_container *parent, int amount, | 182 | static void resize_tiled(struct sway_container *parent, int amount, |
183 | enum resize_axis axis) { | 183 | enum resize_axis axis) { |
184 | struct sway_container *focused = parent; | 184 | struct sway_container *focused = parent; |
185 | if (!parent) { | 185 | if (!parent) { |
186 | return false; | 186 | return; |
187 | } | 187 | } |
188 | 188 | ||
189 | enum sway_container_layout parallel_layout = | 189 | enum sway_container_layout parallel_layout = |
@@ -216,7 +216,7 @@ static bool resize_tiled(struct sway_container *parent, int amount, | |||
216 | } | 216 | } |
217 | if (!parent) { | 217 | if (!parent) { |
218 | // Can't resize in this direction | 218 | // Can't resize in this direction |
219 | return false; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | // Implement up/down/left/right direction by zeroing one of the weights, | 222 | // Implement up/down/left/right direction by zeroing one of the weights, |
@@ -248,22 +248,22 @@ static bool resize_tiled(struct sway_container *parent, int amount, | |||
248 | if (sibling_pos < parent_pos && minor_weight) { | 248 | if (sibling_pos < parent_pos && minor_weight) { |
249 | double pixels = -amount / minor_weight; | 249 | double pixels = -amount / minor_weight; |
250 | if (major_weight && (sibling_size + pixels / 2) < min_sane) { | 250 | if (major_weight && (sibling_size + pixels / 2) < min_sane) { |
251 | return false; // Too small | 251 | return; // Too small |
252 | } else if (!major_weight && sibling_size + pixels < min_sane) { | 252 | } else if (!major_weight && sibling_size + pixels < min_sane) { |
253 | return false; // Too small | 253 | return; // Too small |
254 | } | 254 | } |
255 | } else if (sibling_pos > parent_pos && major_weight) { | 255 | } else if (sibling_pos > parent_pos && major_weight) { |
256 | double pixels = -amount / major_weight; | 256 | double pixels = -amount / major_weight; |
257 | if (minor_weight && (sibling_size + pixels / 2) < min_sane) { | 257 | if (minor_weight && (sibling_size + pixels / 2) < min_sane) { |
258 | return false; // Too small | 258 | return; // Too small |
259 | } else if (!minor_weight && sibling_size + pixels < min_sane) { | 259 | } else if (!minor_weight && sibling_size + pixels < min_sane) { |
260 | return false; // Too small | 260 | return; // Too small |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } else { | 263 | } else { |
264 | double pixels = amount; | 264 | double pixels = amount; |
265 | if (parent_size + pixels < min_sane) { | 265 | if (parent_size + pixels < min_sane) { |
266 | return false; // Too small | 266 | return; // Too small |
267 | } | 267 | } |
268 | } | 268 | } |
269 | } | 269 | } |
@@ -317,10 +317,9 @@ static bool resize_tiled(struct sway_container *parent, int amount, | |||
317 | } else { | 317 | } else { |
318 | arrange_workspace(parent->workspace); | 318 | arrange_workspace(parent->workspace); |
319 | } | 319 | } |
320 | return true; | ||
321 | } | 320 | } |
322 | 321 | ||
323 | bool container_resize_tiled(struct sway_container *parent, | 322 | void container_resize_tiled(struct sway_container *parent, |
324 | enum wlr_edges edge, int amount) { | 323 | enum wlr_edges edge, int amount) { |
325 | enum resize_axis axis = RESIZE_AXIS_INVALID; | 324 | enum resize_axis axis = RESIZE_AXIS_INVALID; |
326 | switch (edge) { | 325 | switch (edge) { |
@@ -339,7 +338,7 @@ bool container_resize_tiled(struct sway_container *parent, | |||
339 | case WLR_EDGE_NONE: | 338 | case WLR_EDGE_NONE: |
340 | break; | 339 | break; |
341 | } | 340 | } |
342 | return resize_tiled(parent, amount, axis); | 341 | resize_tiled(parent, amount, axis); |
343 | } | 342 | } |
344 | 343 | ||
345 | /** | 344 | /** |
@@ -447,7 +446,10 @@ static struct cmd_results *resize_adjust_tiled(enum resize_axis axis, | |||
447 | } | 446 | } |
448 | } | 447 | } |
449 | 448 | ||
450 | if (!resize_tiled(current, amount->amount, axis)) { | 449 | double old_width = current->width; |
450 | double old_height = current->height; | ||
451 | resize_tiled(current, amount->amount, axis); | ||
452 | if (current->width == old_width && current->height == old_height) { | ||
451 | return cmd_results_new(CMD_INVALID, "resize", | 453 | return cmd_results_new(CMD_INVALID, "resize", |
452 | "Cannot resize any further"); | 454 | "Cannot resize any further"); |
453 | } | 455 | } |