aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/resize.c
diff options
context:
space:
mode:
authorLibravatar Konstantin Pospelov <kupospelov@gmail.com>2018-11-25 12:03:04 +0300
committerLibravatar Konstantin Pospelov <kupospelov@gmail.com>2018-11-25 12:33:11 +0300
commita7b9e63cbcacc5dd4629598734a231b9f830670d (patch)
treea8ce9ad4507533c6b5dd6c5c1bda481f2992c759 /sway/commands/resize.c
parentMerge pull request #3145 from fdlamotte/master (diff)
downloadsway-a7b9e63cbcacc5dd4629598734a231b9f830670d.tar.gz
sway-a7b9e63cbcacc5dd4629598734a231b9f830670d.tar.zst
sway-a7b9e63cbcacc5dd4629598734a231b9f830670d.zip
resize set: fix units for floating containers
This commit fixes the default size units for floating containers, so that pixels are used if the units are not specified.
Diffstat (limited to 'sway/commands/resize.c')
-rw-r--r--sway/commands/resize.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index a90d578e..bafaea87 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -512,34 +512,38 @@ 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 case RESIZE_UNIT_INVALID:
528 break;
527 } 529 }
528 } 530 }
529 531
530 if (height->amount) { 532 if (height->amount) {
531 if (height->unit == RESIZE_UNIT_PPT || 533 switch (height->unit) {
532 height->unit == RESIZE_UNIT_DEFAULT) { 534 case RESIZE_UNIT_PPT:
533 // Convert to px 535 // Convert to px
534 height->amount = con->workspace->height * height->amount / 100; 536 height->amount = con->workspace->height * height->amount / 100;
535 height->unit = RESIZE_UNIT_PX; 537 height->unit = RESIZE_UNIT_PX;
536 } 538 // Falls through
537 if (height->unit == RESIZE_UNIT_PX) { 539 case RESIZE_UNIT_PX:
540 case RESIZE_UNIT_DEFAULT:
538 height->amount = fmax(min_height, fmin(height->amount, max_height)); 541 height->amount = fmax(min_height, fmin(height->amount, max_height));
539 grow_height = height->amount - con->height; 542 grow_height = height->amount - con->height;
540
541 con->y -= grow_height / 2; 543 con->y -= grow_height / 2;
542 con->height = height->amount; 544 con->height = height->amount;
545 case RESIZE_UNIT_INVALID:
546 break;
543 } 547 }
544 } 548 }
545 549