summaryrefslogtreecommitdiffstats
path: root/sway/commands/gaps.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/gaps.c')
-rw-r--r--sway/commands/gaps.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c
index aacb792b..801fb179 100644
--- a/sway/commands/gaps.c
+++ b/sway/commands/gaps.c
@@ -31,21 +31,19 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
31 31
32 if (strcmp(argv[1], "on") == 0) { 32 if (strcmp(argv[1], "on") == 0) {
33 config->edge_gaps = true; 33 config->edge_gaps = true;
34 arrange_root();
35 } else if (strcmp(argv[1], "off") == 0) { 34 } else if (strcmp(argv[1], "off") == 0) {
36 config->edge_gaps = false; 35 config->edge_gaps = false;
37 arrange_root();
38 } else if (strcmp(argv[1], "toggle") == 0) { 36 } else if (strcmp(argv[1], "toggle") == 0) {
39 if (!config->active) { 37 if (!config->active) {
40 return cmd_results_new(CMD_INVALID, "gaps", 38 return cmd_results_new(CMD_INVALID, "gaps",
41 "Cannot toggle gaps while not running."); 39 "Cannot toggle gaps while not running.");
42 } 40 }
43 config->edge_gaps = !config->edge_gaps; 41 config->edge_gaps = !config->edge_gaps;
44 arrange_root();
45 } else { 42 } else {
46 return cmd_results_new(CMD_INVALID, "gaps", 43 return cmd_results_new(CMD_INVALID, "gaps",
47 "gaps edge_gaps on|off|toggle"); 44 "gaps edge_gaps on|off|toggle");
48 } 45 }
46 arrange_and_commit(&root_container);
49 } else { 47 } else {
50 int amount_idx = 0; // the current index in argv 48 int amount_idx = 0; // the current index in argv
51 enum gaps_op op = GAPS_OP_SET; 49 enum gaps_op op = GAPS_OP_SET;
@@ -120,13 +118,13 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
120 "gaps inner|outer <amount>"); 118 "gaps inner|outer <amount>");
121 } 119 }
122 return cmd_results_new(CMD_INVALID, "gaps", 120 return cmd_results_new(CMD_INVALID, "gaps",
123 "gaps inner|outer all|workspace|current set|plus|minus <amount>"); 121 "gaps inner|outer all|workspace|current set|plus|minus <amount>");
124 } 122 }
125 123
126 if (amount_idx == 0) { // gaps <amount> 124 if (amount_idx == 0) { // gaps <amount>
127 config->gaps_inner = val; 125 config->gaps_inner = val;
128 config->gaps_outer = val; 126 config->gaps_outer = val;
129 arrange_root(); 127 arrange_and_commit(&root_container);
130 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 128 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
131 } 129 }
132 // Other variants. The middle-length variant (gaps inner|outer <amount>) 130 // Other variants. The middle-length variant (gaps inner|outer <amount>)
@@ -150,14 +148,14 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
150 break; 148 break;
151 } 149 }
152 } 150 }
153 151
154 if (scope == GAPS_SCOPE_ALL) { 152 if (scope == GAPS_SCOPE_ALL) {
155 if (inner) { 153 if (inner) {
156 config->gaps_inner = total; 154 config->gaps_inner = total;
157 } else { 155 } else {
158 config->gaps_outer = total; 156 config->gaps_outer = total;
159 } 157 }
160 arrange_root(); 158 arrange_and_commit(&root_container);
161 } else { 159 } else {
162 struct sway_container *c = 160 struct sway_container *c =
163 config->handler_context.current_container; 161 config->handler_context.current_container;
@@ -171,11 +169,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
171 c->gaps_outer = total; 169 c->gaps_outer = total;
172 } 170 }
173 171
174 if (c->parent) { 172 arrange_and_commit(c->parent ? c->parent : &root_container);
175 arrange_children_of(c->parent);
176 } else {
177 arrange_root();
178 }
179 } 173 }
180 } 174 }
181 175