From 820681965dce9cf7a9b529a96d0126dabf69157a Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 4 Nov 2015 01:05:19 +0100 Subject: [PATCH 1/5] commands: gaps: Refactor, expected_syntax. --- sway/commands.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 43166a1c..497e8eb1 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -760,6 +760,8 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1))) { return error; } + const char* expected_syntax = + "Expected 'gaps '"; const char *amount_str = argv[0]; // gaps amount if (argc >= 1 && isdigit(*amount_str)) { @@ -793,7 +795,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { } // gaps inner|outer current|all set|plus|minus n if (argc < 4 || config->reading) { - return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps '"); + return cmd_results_new(CMD_INVALID, "gaps", expected_syntax); } // gaps inner|outer ... const char *inout_str = argv[0]; @@ -803,7 +805,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { } else if (strcasecmp(inout_str, "outer") == 0) { inout = OUTER; } else { - return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps '"); + return cmd_results_new(CMD_INVALID, "gaps", expected_syntax); } // gaps ... current|all ... @@ -821,7 +823,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { target = WORKSPACE; } } else { - return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps '"); + return cmd_results_new(CMD_INVALID, "gaps", expected_syntax); } // gaps ... n @@ -843,7 +845,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { method = ADD; amount *= -1; } else { - return cmd_results_new(CMD_INVALID, "gaps", "Expected 'gaps '"); + return cmd_results_new(CMD_INVALID, "gaps", expected_syntax); } if (target == CURRENT) { From 62226460dd7eb878b960d3af03dbdce03f853c20 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 4 Nov 2015 01:26:23 +0100 Subject: [PATCH 2/5] sway.5.txt: Clarify gaps documentation. --- sway.5.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sway.5.txt b/sway.5.txt index 30b57d4a..5659a107 100644 --- a/sway.5.txt +++ b/sway.5.txt @@ -69,18 +69,18 @@ Commands Toggles fullscreen status for the focused view. **gaps** :: - Sets _amount_ pixels as the gap between each view, and around each + Sets default _amount_ pixels as the gap between each view, and around each workspace. **gaps** :: - Sets _amount_ pixels as the _inner_ or _outer_ gap, where the former affects - spacing between views and the latter affects the space around each + Sets default _amount_ pixels as the _inner_ or _outer_ gap, where the former + affects spacing between views and the latter affects the space around each workspace. **gaps** :: Changes the gaps for the _inner_ or _outer_ gap. _all_ changes the gaps for all views or workspace, _workspace_ changes gaps for all views in current - workspace, or current workspace, and _current_ changes gaps for the current + workspace (or current workspace), and _current_ changes gaps for the current view or workspace. **kill**:: From 5c1e20b6ff0064f5ed948fc51ed029dd613f33db Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 4 Nov 2015 00:41:28 +0100 Subject: [PATCH 3/5] commands: gaps: Accept zero value. --- sway/commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 497e8eb1..7bfb71ba 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -766,7 +766,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { // gaps amount if (argc >= 1 && isdigit(*amount_str)) { int amount = (int)strtol(amount_str, NULL, 10); - if (errno == ERANGE || amount == 0) { + if (errno == ERANGE) { errno = 0; return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); } @@ -781,7 +781,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { // gaps inner|outer n else if (argc >= 2 && isdigit((amount_str = argv[1])[0])) { int amount = (int)strtol(amount_str, NULL, 10); - if (errno == ERANGE || amount == 0) { + if (errno == ERANGE) { errno = 0; return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); } @@ -829,7 +829,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { // gaps ... n amount_str = argv[3]; int amount = (int)strtol(amount_str, NULL, 10); - if (errno == ERANGE || amount == 0) { + if (errno == ERANGE) { errno = 0; return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); } From 936f8c24e076189b8a70d4fcc4854f94346c18fe Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 4 Nov 2015 01:27:02 +0100 Subject: [PATCH 4/5] commands: gaps: Always apply default gaps config. --- sway/commands.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 7bfb71ba..9d4f74aa 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -770,12 +770,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { errno = 0; return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); } - if (config->gaps_inner == 0) { - config->gaps_inner = amount; - } - if (config->gaps_outer == 0) { - config->gaps_outer = amount; - } + config->gaps_inner = config->gaps_outer = amount; return cmd_results_new(CMD_SUCCESS, NULL, NULL); } // gaps inner|outer n From eeec0fda8a856d67b7ddf4432a504589989e20e2 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 4 Nov 2015 01:27:24 +0100 Subject: [PATCH 5/5] commands: gaps: Re-arrange windows after changing default gaps. --- sway/commands.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sway/commands.c b/sway/commands.c index 9d4f74aa..19b8e1a9 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -771,6 +771,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "gaps", "Number is out out of range."); } config->gaps_inner = config->gaps_outer = amount; + arrange_windows(&root_container, -1, -1); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } // gaps inner|outer n @@ -786,6 +787,7 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { } else if (strcasecmp(target_str, "outer") == 0) { config->gaps_outer = amount; } + arrange_windows(&root_container, -1, -1); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } // gaps inner|outer current|all set|plus|minus n