diff options
author | emersion <contact@emersion.fr> | 2018-11-25 17:41:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-25 17:41:45 +0100 |
commit | 91bbb2a7ddded2e956c50226d0f0207cd7da550e (patch) | |
tree | 34e05cda5a5ee1e95a1df679d0aa08e88e720554 | |
parent | Merge pull request #3049 from ianyfan/swayidle (diff) | |
parent | resize set: add assertion for an invalid unit (diff) | |
download | sway-91bbb2a7ddded2e956c50226d0f0207cd7da550e.tar.gz sway-91bbb2a7ddded2e956c50226d0f0207cd7da550e.tar.zst sway-91bbb2a7ddded2e956c50226d0f0207cd7da550e.zip |
Merge pull request #3184 from kupospelov/fix-resize
resize set: fix units for floating containers
-rw-r--r-- | sway/commands/resize.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index a90d578e..cf5dea02 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -512,34 +512,42 @@ static struct cmd_results *resize_set_floating(struct sway_container *con, | |||
512 | calculate_constraints(&min_width, &max_width, &min_height, &max_height); | 512 | calculate_constraints(&min_width, &max_width, &min_height, &max_height); |
513 | 513 | ||
514 | if (width->amount) { | 514 | if (width->amount) { |
515 | if (width->unit == RESIZE_UNIT_PPT || | 515 | switch (width->unit) { |
516 | width->unit == RESIZE_UNIT_DEFAULT) { | 516 | case RESIZE_UNIT_PPT: |
517 | // Convert to px | 517 | // Convert to px |
518 | width->amount = con->workspace->width * width->amount / 100; | 518 | width->amount = con->workspace->width * width->amount / 100; |
519 | width->unit = RESIZE_UNIT_PX; | 519 | width->unit = RESIZE_UNIT_PX; |
520 | } | 520 | // Falls through |
521 | if (width->unit == RESIZE_UNIT_PX) { | 521 | case RESIZE_UNIT_PX: |
522 | case RESIZE_UNIT_DEFAULT: | ||
522 | width->amount = fmax(min_width, fmin(width->amount, max_width)); | 523 | width->amount = fmax(min_width, fmin(width->amount, max_width)); |
523 | grow_width = width->amount - con->width; | 524 | grow_width = width->amount - con->width; |
524 | |||
525 | con->x -= grow_width / 2; | 525 | con->x -= grow_width / 2; |
526 | con->width = width->amount; | 526 | con->width = width->amount; |
527 | break; | ||
528 | case RESIZE_UNIT_INVALID: | ||
529 | sway_assert(false, "invalid width unit"); | ||
530 | break; | ||
527 | } | 531 | } |
528 | } | 532 | } |
529 | 533 | ||
530 | if (height->amount) { | 534 | if (height->amount) { |
531 | if (height->unit == RESIZE_UNIT_PPT || | 535 | switch (height->unit) { |
532 | height->unit == RESIZE_UNIT_DEFAULT) { | 536 | case RESIZE_UNIT_PPT: |
533 | // Convert to px | 537 | // Convert to px |
534 | height->amount = con->workspace->height * height->amount / 100; | 538 | height->amount = con->workspace->height * height->amount / 100; |
535 | height->unit = RESIZE_UNIT_PX; | 539 | height->unit = RESIZE_UNIT_PX; |
536 | } | 540 | // Falls through |
537 | if (height->unit == RESIZE_UNIT_PX) { | 541 | case RESIZE_UNIT_PX: |
542 | case RESIZE_UNIT_DEFAULT: | ||
538 | height->amount = fmax(min_height, fmin(height->amount, max_height)); | 543 | height->amount = fmax(min_height, fmin(height->amount, max_height)); |
539 | grow_height = height->amount - con->height; | 544 | grow_height = height->amount - con->height; |
540 | |||
541 | con->y -= grow_height / 2; | 545 | con->y -= grow_height / 2; |
542 | con->height = height->amount; | 546 | con->height = height->amount; |
547 | break; | ||
548 | case RESIZE_UNIT_INVALID: | ||
549 | sway_assert(false, "invalid height unit"); | ||
550 | break; | ||
543 | } | 551 | } |
544 | } | 552 | } |
545 | 553 | ||