diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-18 18:07:51 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-18 18:07:51 -0400 |
commit | 446d593b4ca5cf4ea5bbf9eaafe8a6f3521b4189 (patch) | |
tree | 97279d1259c4e049a74af4efa3e4b2334a6cae74 /sway/commands.c | |
parent | 8e201091a52a74d87db18c18a21fc39aedb95eb2 (diff) | |
parent | c75d5ceba475e3c6d1fae475c610c53909a83a29 (diff) |
Merge pull request #73 from KoffeinFlummi/gaps
Add support for gaps option
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 6c3efb3b..54839322 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -3,6 +3,7 @@ #include <wlc/wlc.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> #include <string.h> #include <unistd.h> #include <ctype.h> @@ -281,6 +282,44 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char * return true; } +static bool cmd_gaps(struct sway_config *config, int argc, char **argv) { + if (!checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1)) { + return false; + } + + if (argc == 1) { + char *end; + int amount = (int)strtol(argv[0], &end, 10); + if (errno == ERANGE || amount == 0) { + errno = 0; + return false; + } + if (config->gaps_inner == 0) { + config->gaps_inner = amount; + } + if (config->gaps_outer == 0) { + config->gaps_outer = amount; + } + } else if (argc == 2) { + char *end; + int amount = (int)strtol(argv[1], &end, 10); + if (errno == ERANGE || amount == 0) { + errno = 0; + return false; + } + if (strcmp(argv[0], "inner") == 0) { + config->gaps_inner = amount; + } else if (strcmp(argv[0], "outer") == 0) { + config->gaps_outer = amount; + } else { + return false; + } + } else { + return false; + } + return true; +} + static bool cmd_kill(struct sway_config *config, int argc, char **argv) { swayc_t *view = get_focused_container(&root_container); wlc_view_close(view->handle); @@ -484,6 +523,7 @@ static struct cmd_handler handlers[] = { { "focus", cmd_focus }, { "focus_follows_mouse", cmd_focus_follows_mouse }, { "fullscreen", cmd_fullscreen }, + { "gaps", cmd_gaps }, { "kill", cmd_kill }, { "layout", cmd_layout }, { "log_colors", cmd_log_colors }, |