summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 43166a1c..19b8e1a9 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -760,26 +760,24 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
760 if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1))) { 760 if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1))) {
761 return error; 761 return error;
762 } 762 }
763 const char* expected_syntax =
764 "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'";
763 const char *amount_str = argv[0]; 765 const char *amount_str = argv[0];
764 // gaps amount 766 // gaps amount
765 if (argc >= 1 && isdigit(*amount_str)) { 767 if (argc >= 1 && isdigit(*amount_str)) {
766 int amount = (int)strtol(amount_str, NULL, 10); 768 int amount = (int)strtol(amount_str, NULL, 10);
767 if (errno == ERANGE || amount == 0) { 769 if (errno == ERANGE) {
768 errno = 0; 770 errno = 0;
769 return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); 771 return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range.");
770 } 772 }
771 if (config->gaps_inner == 0) { 773 config->gaps_inner = config->gaps_outer = amount;
772 config->gaps_inner = amount; 774 arrange_windows(&root_container, -1, -1);
773 }
774 if (config->gaps_outer == 0) {
775 config->gaps_outer = amount;
776 }
777 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 775 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
778 } 776 }
779 // gaps inner|outer n 777 // gaps inner|outer n
780 else if (argc >= 2 && isdigit((amount_str = argv[1])[0])) { 778 else if (argc >= 2 && isdigit((amount_str = argv[1])[0])) {
781 int amount = (int)strtol(amount_str, NULL, 10); 779 int amount = (int)strtol(amount_str, NULL, 10);
782 if (errno == ERANGE || amount == 0) { 780 if (errno == ERANGE) {
783 errno = 0; 781 errno = 0;
784 return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); 782 return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range.");
785 } 783 }
@@ -789,11 +787,12 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
789 } else if (strcasecmp(target_str, "outer") == 0) { 787 } else if (strcasecmp(target_str, "outer") == 0) {
790 config->gaps_outer = amount; 788 config->gaps_outer = amount;
791 } 789 }
790 arrange_windows(&root_container, -1, -1);
792 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 791 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
793 } 792 }
794 // gaps inner|outer current|all set|plus|minus n 793 // gaps inner|outer current|all set|plus|minus n
795 if (argc < 4 || config->reading) { 794 if (argc < 4 || config->reading) {
796 return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'"); 795 return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
797 } 796 }
798 // gaps inner|outer ... 797 // gaps inner|outer ...
799 const char *inout_str = argv[0]; 798 const char *inout_str = argv[0];
@@ -803,7 +802,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
803 } else if (strcasecmp(inout_str, "outer") == 0) { 802 } else if (strcasecmp(inout_str, "outer") == 0) {
804 inout = OUTER; 803 inout = OUTER;
805 } else { 804 } else {
806 return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'"); 805 return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
807 } 806 }
808 807
809 // gaps ... current|all ... 808 // gaps ... current|all ...
@@ -821,13 +820,13 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
821 target = WORKSPACE; 820 target = WORKSPACE;
822 } 821 }
823 } else { 822 } else {
824 return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'"); 823 return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
825 } 824 }
826 825
827 // gaps ... n 826 // gaps ... n
828 amount_str = argv[3]; 827 amount_str = argv[3];
829 int amount = (int)strtol(amount_str, NULL, 10); 828 int amount = (int)strtol(amount_str, NULL, 10);
830 if (errno == ERANGE || amount == 0) { 829 if (errno == ERANGE) {
831 errno = 0; 830 errno = 0;
832 return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); 831 return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range.");
833 } 832 }
@@ -843,7 +842,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) {
843 method = ADD; 842 method = ADD;
844 amount *= -1; 843 amount *= -1;
845 } else { 844 } else {
846 return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps <inner|outer> <current|all> <set|plus|minus n>'"); 845 return cmd_results_new(CMD_INVALID, "gaps", expected_syntax);
847 } 846 }
848 847
849 if (target == CURRENT) { 848 if (target == CURRENT) {