diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sway/commands.c b/sway/commands.c index ede6c60c..b09a04c7 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -174,10 +174,11 @@ static const struct cmd_handler *find_core_handler(char *line) { | |||
174 | handlers, sizeof(handlers)); | 174 | handlers, sizeof(handlers)); |
175 | } | 175 | } |
176 | 176 | ||
177 | static void set_config_node(struct sway_node *node) { | 177 | static void set_config_node(struct sway_node *node, bool node_overridden) { |
178 | config->handler_context.node = node; | 178 | config->handler_context.node = node; |
179 | config->handler_context.container = NULL; | 179 | config->handler_context.container = NULL; |
180 | config->handler_context.workspace = NULL; | 180 | config->handler_context.workspace = NULL; |
181 | config->handler_context.node_overridden = node_overridden; | ||
181 | 182 | ||
182 | if (node == NULL) { | 183 | if (node == NULL) { |
183 | return; | 184 | return; |
@@ -202,6 +203,7 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, | |||
202 | char *cmd; | 203 | char *cmd; |
203 | char matched_delim = ';'; | 204 | char matched_delim = ';'; |
204 | list_t *containers = NULL; | 205 | list_t *containers = NULL; |
206 | bool using_criteria = false; | ||
205 | 207 | ||
206 | if (seat == NULL) { | 208 | if (seat == NULL) { |
207 | // passing a NULL seat means we just pick the default seat | 209 | // passing a NULL seat means we just pick the default seat |
@@ -225,7 +227,7 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, | |||
225 | for (; isspace(*head); ++head) {} | 227 | for (; isspace(*head); ++head) {} |
226 | // Extract criteria (valid for this command list only). | 228 | // Extract criteria (valid for this command list only). |
227 | if (matched_delim == ';') { | 229 | if (matched_delim == ';') { |
228 | config->handler_context.using_criteria = false; | 230 | using_criteria = false; |
229 | if (*head == '[') { | 231 | if (*head == '[') { |
230 | char *error = NULL; | 232 | char *error = NULL; |
231 | struct criteria *criteria = criteria_parse(head, &error); | 233 | struct criteria *criteria = criteria_parse(head, &error); |
@@ -239,7 +241,7 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, | |||
239 | containers = criteria_get_containers(criteria); | 241 | containers = criteria_get_containers(criteria); |
240 | head += strlen(criteria->raw); | 242 | head += strlen(criteria->raw); |
241 | criteria_destroy(criteria); | 243 | criteria_destroy(criteria); |
242 | config->handler_context.using_criteria = true; | 244 | using_criteria = true; |
243 | // Skip leading whitespace | 245 | // Skip leading whitespace |
244 | for (; isspace(*head); ++head) {} | 246 | for (; isspace(*head); ++head) {} |
245 | } | 247 | } |
@@ -278,11 +280,14 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, | |||
278 | argv[i] = do_var_replacement(argv[i]); | 280 | argv[i] = do_var_replacement(argv[i]); |
279 | } | 281 | } |
280 | 282 | ||
281 | if (!config->handler_context.using_criteria) { | 283 | |
282 | // The container or workspace which this command will run on. | 284 | if (!using_criteria) { |
283 | struct sway_node *node = con ? &con->node : | 285 | if (con) { |
284 | seat_get_focus_inactive(seat, &root->node); | 286 | set_config_node(&con->node, true); |
285 | set_config_node(node); | 287 | } else { |
288 | set_config_node(seat_get_focus_inactive(seat, &root->node), | ||
289 | false); | ||
290 | } | ||
286 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 291 | struct cmd_results *res = handler->handle(argc-1, argv+1); |
287 | list_add(res_list, res); | 292 | list_add(res_list, res); |
288 | if (res->status == CMD_INVALID) { | 293 | if (res->status == CMD_INVALID) { |
@@ -296,7 +301,7 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, | |||
296 | struct cmd_results *fail_res = NULL; | 301 | struct cmd_results *fail_res = NULL; |
297 | for (int i = 0; i < containers->length; ++i) { | 302 | for (int i = 0; i < containers->length; ++i) { |
298 | struct sway_container *container = containers->items[i]; | 303 | struct sway_container *container = containers->items[i]; |
299 | set_config_node(&container->node); | 304 | set_config_node(&container->node, true); |
300 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 305 | struct cmd_results *res = handler->handle(argc-1, argv+1); |
301 | if (res->status == CMD_SUCCESS) { | 306 | if (res->status == CMD_SUCCESS) { |
302 | free_cmd_results(res); | 307 | free_cmd_results(res); |