diff options
author | KoffeinFlummi <koffeinflummi@gmail.com> | 2015-08-18 23:53:57 +0200 |
---|---|---|
committer | KoffeinFlummi <koffeinflummi@gmail.com> | 2015-08-18 23:53:57 +0200 |
commit | 4c688cba4e3528921656d63a09f7015cae13cd0c (patch) | |
tree | e6f0a07953c900973a48abf467979c0e325c7389 /sway/commands.c | |
parent | 2139001c9f61a84ed1ac581a54bb2bde68928afd (diff) |
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 51de7a50..f716efa3 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 }, |