diff options
Diffstat (limited to 'sway/commands/resize.c')
-rw-r--r-- | sway/commands/resize.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 0e849afc..fad1ecb1 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -340,8 +340,7 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis, | |||
340 | grow_x = -grow_width; | 340 | grow_x = -grow_width; |
341 | } | 341 | } |
342 | if (grow_x == 0 && grow_y == 0) { | 342 | if (grow_x == 0 && grow_y == 0) { |
343 | return cmd_results_new(CMD_INVALID, "resize", | 343 | return cmd_results_new(CMD_INVALID, "Cannot resize any further"); |
344 | "Cannot resize any further"); | ||
345 | } | 344 | } |
346 | con->x += grow_x; | 345 | con->x += grow_x; |
347 | con->y += grow_y; | 346 | con->y += grow_y; |
@@ -355,7 +354,7 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis, | |||
355 | 354 | ||
356 | arrange_container(con); | 355 | arrange_container(con); |
357 | 356 | ||
358 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 357 | return cmd_results_new(CMD_SUCCESS, NULL); |
359 | } | 358 | } |
360 | 359 | ||
361 | /** | 360 | /** |
@@ -382,10 +381,9 @@ static struct cmd_results *resize_adjust_tiled(uint32_t axis, | |||
382 | double old_height = current->height; | 381 | double old_height = current->height; |
383 | resize_tiled(current, amount->amount, axis); | 382 | resize_tiled(current, amount->amount, axis); |
384 | if (current->width == old_width && current->height == old_height) { | 383 | if (current->width == old_width && current->height == old_height) { |
385 | return cmd_results_new(CMD_INVALID, "resize", | 384 | return cmd_results_new(CMD_INVALID, "Cannot resize any further"); |
386 | "Cannot resize any further"); | ||
387 | } | 385 | } |
388 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 386 | return cmd_results_new(CMD_SUCCESS, NULL); |
389 | } | 387 | } |
390 | 388 | ||
391 | /** | 389 | /** |
@@ -433,7 +431,7 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con, | |||
433 | } | 431 | } |
434 | } | 432 | } |
435 | 433 | ||
436 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 434 | return cmd_results_new(CMD_SUCCESS, NULL); |
437 | } | 435 | } |
438 | 436 | ||
439 | /** | 437 | /** |
@@ -491,7 +489,7 @@ static struct cmd_results *resize_set_floating(struct sway_container *con, | |||
491 | 489 | ||
492 | arrange_container(con); | 490 | arrange_container(con); |
493 | 491 | ||
494 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 492 | return cmd_results_new(CMD_SUCCESS, NULL); |
495 | } | 493 | } |
496 | 494 | ||
497 | /** | 495 | /** |
@@ -506,7 +504,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { | |||
506 | if ((error = checkarg(argc, "resize", EXPECTED_AT_LEAST, 1))) { | 504 | if ((error = checkarg(argc, "resize", EXPECTED_AT_LEAST, 1))) { |
507 | return error; | 505 | return error; |
508 | } | 506 | } |
509 | const char *usage = "Expected 'resize set [width] <width> [px|ppt]' or " | 507 | const char usage[] = "Expected 'resize set [width] <width> [px|ppt]' or " |
510 | "'resize set height <height> [px|ppt]' or " | 508 | "'resize set height <height> [px|ppt]' or " |
511 | "'resize set [width] <width> [px|ppt] [height] <height> [px|ppt]'"; | 509 | "'resize set [width] <width> [px|ppt] [height] <height> [px|ppt]'"; |
512 | 510 | ||
@@ -520,7 +518,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { | |||
520 | argc -= num_consumed_args; | 518 | argc -= num_consumed_args; |
521 | argv += num_consumed_args; | 519 | argv += num_consumed_args; |
522 | if (width.unit == RESIZE_UNIT_INVALID) { | 520 | if (width.unit == RESIZE_UNIT_INVALID) { |
523 | return cmd_results_new(CMD_INVALID, "resize set", usage); | 521 | return cmd_results_new(CMD_INVALID, usage); |
524 | } | 522 | } |
525 | } | 523 | } |
526 | 524 | ||
@@ -534,7 +532,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { | |||
534 | argc -= num_consumed_args; | 532 | argc -= num_consumed_args; |
535 | argv += num_consumed_args; | 533 | argv += num_consumed_args; |
536 | if (width.unit == RESIZE_UNIT_INVALID) { | 534 | if (width.unit == RESIZE_UNIT_INVALID) { |
537 | return cmd_results_new(CMD_INVALID, "resize set", usage); | 535 | return cmd_results_new(CMD_INVALID, usage); |
538 | } | 536 | } |
539 | } | 537 | } |
540 | 538 | ||
@@ -562,11 +560,11 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { | |||
562 | */ | 560 | */ |
563 | static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | 561 | static struct cmd_results *cmd_resize_adjust(int argc, char **argv, |
564 | int multiplier) { | 562 | int multiplier) { |
565 | const char *usage = "Expected 'resize grow|shrink <direction> " | 563 | const char usage[] = "Expected 'resize grow|shrink <direction> " |
566 | "[<amount> px|ppt [or <amount> px|ppt]]'"; | 564 | "[<amount> px|ppt [or <amount> px|ppt]]'"; |
567 | uint32_t axis = parse_resize_axis(*argv); | 565 | uint32_t axis = parse_resize_axis(*argv); |
568 | if (axis == WLR_EDGE_NONE) { | 566 | if (axis == WLR_EDGE_NONE) { |
569 | return cmd_results_new(CMD_INVALID, "resize", usage); | 567 | return cmd_results_new(CMD_INVALID, usage); |
570 | } | 568 | } |
571 | --argc; ++argv; | 569 | --argc; ++argv; |
572 | 570 | ||
@@ -577,7 +575,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
577 | argc -= num_consumed_args; | 575 | argc -= num_consumed_args; |
578 | argv += num_consumed_args; | 576 | argv += num_consumed_args; |
579 | if (first_amount.unit == RESIZE_UNIT_INVALID) { | 577 | if (first_amount.unit == RESIZE_UNIT_INVALID) { |
580 | return cmd_results_new(CMD_INVALID, "resize", usage); | 578 | return cmd_results_new(CMD_INVALID, usage); |
581 | } | 579 | } |
582 | } else { | 580 | } else { |
583 | first_amount.amount = 10; | 581 | first_amount.amount = 10; |
@@ -587,7 +585,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
587 | // "or" | 585 | // "or" |
588 | if (argc) { | 586 | if (argc) { |
589 | if (strcmp(*argv, "or") != 0) { | 587 | if (strcmp(*argv, "or") != 0) { |
590 | return cmd_results_new(CMD_INVALID, "resize", usage); | 588 | return cmd_results_new(CMD_INVALID, usage); |
591 | } | 589 | } |
592 | --argc; ++argv; | 590 | --argc; ++argv; |
593 | } | 591 | } |
@@ -599,7 +597,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
599 | argc -= num_consumed_args; | 597 | argc -= num_consumed_args; |
600 | argv += num_consumed_args; | 598 | argv += num_consumed_args; |
601 | if (second_amount.unit == RESIZE_UNIT_INVALID) { | 599 | if (second_amount.unit == RESIZE_UNIT_INVALID) { |
602 | return cmd_results_new(CMD_INVALID, "resize", usage); | 600 | return cmd_results_new(CMD_INVALID, usage); |
603 | } | 601 | } |
604 | } else { | 602 | } else { |
605 | second_amount.unit = RESIZE_UNIT_INVALID; | 603 | second_amount.unit = RESIZE_UNIT_INVALID; |
@@ -621,7 +619,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
621 | } else if (second_amount.unit == RESIZE_UNIT_DEFAULT) { | 619 | } else if (second_amount.unit == RESIZE_UNIT_DEFAULT) { |
622 | return resize_adjust_floating(axis, &second_amount); | 620 | return resize_adjust_floating(axis, &second_amount); |
623 | } else { | 621 | } else { |
624 | return cmd_results_new(CMD_INVALID, "resize", | 622 | return cmd_results_new(CMD_INVALID, |
625 | "Floating containers cannot use ppt measurements"); | 623 | "Floating containers cannot use ppt measurements"); |
626 | } | 624 | } |
627 | } | 625 | } |
@@ -642,12 +640,12 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
642 | 640 | ||
643 | struct cmd_results *cmd_resize(int argc, char **argv) { | 641 | struct cmd_results *cmd_resize(int argc, char **argv) { |
644 | if (!root->outputs->length) { | 642 | if (!root->outputs->length) { |
645 | return cmd_results_new(CMD_INVALID, "resize", | 643 | return cmd_results_new(CMD_INVALID, |
646 | "Can't run this command while there's no outputs connected."); | 644 | "Can't run this command while there's no outputs connected."); |
647 | } | 645 | } |
648 | struct sway_container *current = config->handler_context.container; | 646 | struct sway_container *current = config->handler_context.container; |
649 | if (!current) { | 647 | if (!current) { |
650 | return cmd_results_new(CMD_INVALID, "resize", "Cannot resize nothing"); | 648 | return cmd_results_new(CMD_INVALID, "Cannot resize nothing"); |
651 | } | 649 | } |
652 | 650 | ||
653 | struct cmd_results *error; | 651 | struct cmd_results *error; |
@@ -665,8 +663,8 @@ struct cmd_results *cmd_resize(int argc, char **argv) { | |||
665 | return cmd_resize_adjust(argc - 1, &argv[1], -1); | 663 | return cmd_resize_adjust(argc - 1, &argv[1], -1); |
666 | } | 664 | } |
667 | 665 | ||
668 | const char *usage = "Expected 'resize <shrink|grow> " | 666 | const char usage[] = "Expected 'resize <shrink|grow> " |
669 | "<width|height|up|down|left|right> [<amount>] [px|ppt]'"; | 667 | "<width|height|up|down|left|right> [<amount>] [px|ppt]'"; |
670 | 668 | ||
671 | return cmd_results_new(CMD_INVALID, "resize", usage); | 669 | return cmd_results_new(CMD_INVALID, usage); |
672 | } | 670 | } |