diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sway/commands.c b/sway/commands.c index e72b8916..b32628cd 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -212,6 +212,24 @@ struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers, | |||
212 | return res; | 212 | return res; |
213 | } | 213 | } |
214 | 214 | ||
215 | static void set_config_node(struct sway_node *node) { | ||
216 | config->handler_context.node = node; | ||
217 | switch (node->type) { | ||
218 | case N_CONTAINER: | ||
219 | config->handler_context.container = node->sway_container; | ||
220 | config->handler_context.workspace = node->sway_container->workspace; | ||
221 | break; | ||
222 | case N_WORKSPACE: | ||
223 | config->handler_context.container = NULL; | ||
224 | config->handler_context.workspace = node->sway_workspace; | ||
225 | break; | ||
226 | default: | ||
227 | config->handler_context.container = NULL; | ||
228 | config->handler_context.workspace = NULL; | ||
229 | break; | ||
230 | } | ||
231 | } | ||
232 | |||
215 | struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { | 233 | struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { |
216 | // Even though this function will process multiple commands we will only | 234 | // Even though this function will process multiple commands we will only |
217 | // return the last error, if any (for now). (Since we have access to an | 235 | // return the last error, if any (for now). (Since we have access to an |
@@ -295,12 +313,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { | |||
295 | if (!config->handler_context.using_criteria) { | 313 | if (!config->handler_context.using_criteria) { |
296 | // without criteria, the command acts upon the focused | 314 | // without criteria, the command acts upon the focused |
297 | // container | 315 | // container |
298 | config->handler_context.current_container = | 316 | set_config_node(seat_get_focus_inactive(seat, &root->node)); |
299 | seat_get_focus_inactive(seat, &root_container); | ||
300 | if (!sway_assert(config->handler_context.current_container, | ||
301 | "could not get focus-inactive for root container")) { | ||
302 | return NULL; | ||
303 | } | ||
304 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 317 | struct cmd_results *res = handler->handle(argc-1, argv+1); |
305 | if (res->status != CMD_SUCCESS) { | 318 | if (res->status != CMD_SUCCESS) { |
306 | free_argv(argc, argv); | 319 | free_argv(argc, argv); |
@@ -314,7 +327,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { | |||
314 | } else { | 327 | } else { |
315 | for (int i = 0; i < views->length; ++i) { | 328 | for (int i = 0; i < views->length; ++i) { |
316 | struct sway_view *view = views->items[i]; | 329 | struct sway_view *view = views->items[i]; |
317 | config->handler_context.current_container = view->swayc; | 330 | set_config_node(&view->container->node); |
318 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 331 | struct cmd_results *res = handler->handle(argc-1, argv+1); |
319 | if (res->status != CMD_SUCCESS) { | 332 | if (res->status != CMD_SUCCESS) { |
320 | free_argv(argc, argv); | 333 | free_argv(argc, argv); |