aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
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 @@
1#define _XOPEN_SOURCE 500 1#define _XOPEN_SOURCE 500
2#include <ctype.h> 2#include <ctype.h>
3#include <limits.h>
3#include <string.h> 4#include <string.h>
4#include <strings.h> 5#include <strings.h>
5#include "sway/commands.h" 6#include "sway/commands.h"
@@ -20,8 +21,8 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
20 return NULL; 21 return NULL;
21 } 22 }
22 wsc->workspace = strdup(ws_name); 23 wsc->workspace = strdup(ws_name);
23 wsc->gaps_inner = -1; 24 wsc->gaps_inner = INT_MIN;
24 wsc->gaps_outer = -1; 25 wsc->gaps_outer = INT_MIN;
25 list_add(config->workspace_configs, wsc); 26 list_add(config->workspace_configs, wsc);
26 return wsc; 27 return wsc;
27} 28}
@@ -94,7 +95,16 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
94 return cmd_results_new(CMD_FAILURE, "workspace gaps", 95 return cmd_results_new(CMD_FAILURE, "workspace gaps",
95 "Expected 'workspace <ws> gaps inner|outer <px>'"); 96 "Expected 'workspace <ws> gaps inner|outer <px>'");
96 } 97 }
97 *prop = val >= 0 ? val : 0; 98 *prop = val;
99
100 // Prevent invalid gaps configurations.
101 if (wsc->gaps_inner < 0) {
102 wsc->gaps_inner = 0;
103 }
104 if (wsc->gaps_outer < -wsc->gaps_inner) {
105 wsc->gaps_outer = -wsc->gaps_inner;
106 }
107
98 } else { 108 } else {
99 if (config->reading || !config->active) { 109 if (config->reading || !config->active) {
100 return cmd_results_new(CMD_DEFER, "workspace", NULL); 110 return cmd_results_new(CMD_DEFER, "workspace", NULL);