From 1156523ccf8b45102333cca7d80b3451930b48e8 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 21 Jan 2018 08:46:31 -0500 Subject: run all commands with focused container context --- sway/commands.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index c1e25c5f..3ab5add6 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -11,6 +11,7 @@ #include "sway/criteria.h" #include "sway/security.h" #include "sway/input/input-manager.h" +#include "sway/input/seat.h" #include "stringop.h" #include "log.h" @@ -271,19 +272,26 @@ struct cmd_results *handle_command(char *_exec) { } if (!has_criteria) { - config->handler_context.current_container = NULL; - struct cmd_results *res = handler->handle(argc-1, argv+1); - if (res->status != CMD_SUCCESS) { - free_argv(argc, argv); - if (results) { - free_cmd_results(results); + // without criteria, the command acts upon the focused + // container + struct sway_seat *seat = config->handler_context.seat; + if (!seat) { + seat = sway_input_manager_get_default_seat(input_manager); + } + if (seat) { + config->handler_context.current_container = seat->focus; + struct cmd_results *res = handler->handle(argc-1, argv+1); + if (res->status != CMD_SUCCESS) { + free_argv(argc, argv); + if (results) { + free_cmd_results(results); + } + results = res; + goto cleanup; } - results = res; - goto cleanup; + free_cmd_results(res); } - free_cmd_results(res); } else { - wlr_log(L_DEBUG, "@@ running command on containers"); for (int i = 0; i < containers->length; ++i) { config->handler_context.current_container = containers->items[i]; struct cmd_results *res = handler->handle(argc-1, argv+1); -- cgit v1.2.3-54-g00ecf