summaryrefslogtreecommitdiff
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
authorBrian Ashworth <[email protected]>2018-10-13 18:49:31 -0400
committerGitHub <[email protected]>2018-10-13 18:49:31 -0400
commit350f7d34605264eb029f6f7d88d6a54e81f455ed (patch)
tree874a3157f2778518a87009c35b47de9d5451b257 /sway/commands/workspace.c
parent782a835175b1fecb427fbbafef4e7518af95329f (diff)
parent02aeb0f0bec90f87acbdbce41d34109b26e9dc5d (diff)
Merge pull request #2823 from tarmack/fix_edge_gaps
Fix edge gaps
Diffstat (limited to 'sway/commands/workspace.c')
-rw-r--r--sway/commands/workspace.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 63f29641..61aa443d 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -1,5 +1,6 @@
#define _XOPEN_SOURCE 500
#include <ctype.h>
+#include <limits.h>
#include <string.h>
#include <strings.h>
#include "sway/commands.h"
@@ -20,8 +21,8 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
return NULL;
}
wsc->workspace = strdup(ws_name);
- wsc->gaps_inner = -1;
- wsc->gaps_outer = -1;
+ wsc->gaps_inner = INT_MIN;
+ wsc->gaps_outer = INT_MIN;
list_add(config->workspace_configs, wsc);
return wsc;
}
@@ -94,7 +95,16 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
return cmd_results_new(CMD_FAILURE, "workspace gaps",
"Expected 'workspace <ws> gaps inner|outer <px>'");
}
- *prop = val >= 0 ? val : 0;
+ *prop = val;
+
+ // Prevent invalid gaps configurations.
+ if (wsc->gaps_inner < 0) {
+ wsc->gaps_inner = 0;
+ }
+ if (wsc->gaps_outer < -wsc->gaps_inner) {
+ wsc->gaps_outer = -wsc->gaps_inner;
+ }
+
} else {
if (config->reading || !config->active) {
return cmd_results_new(CMD_DEFER, "workspace", NULL);