diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-01-21 08:46:31 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-01-21 08:46:31 -0500 |
commit | 1156523ccf8b45102333cca7d80b3451930b48e8 (patch) | |
tree | 9ffcf90b69ee2940862c1add1f2fdf02dcd24da9 /sway/commands.c | |
parent | basic command criteria (diff) | |
download | sway-1156523ccf8b45102333cca7d80b3451930b48e8.tar.gz sway-1156523ccf8b45102333cca7d80b3451930b48e8.tar.zst sway-1156523ccf8b45102333cca7d80b3451930b48e8.zip |
run all commands with focused container context
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 28 |
1 files changed, 18 insertions, 10 deletions
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 @@ | |||
11 | #include "sway/criteria.h" | 11 | #include "sway/criteria.h" |
12 | #include "sway/security.h" | 12 | #include "sway/security.h" |
13 | #include "sway/input/input-manager.h" | 13 | #include "sway/input/input-manager.h" |
14 | #include "sway/input/seat.h" | ||
14 | #include "stringop.h" | 15 | #include "stringop.h" |
15 | #include "log.h" | 16 | #include "log.h" |
16 | 17 | ||
@@ -271,19 +272,26 @@ struct cmd_results *handle_command(char *_exec) { | |||
271 | } | 272 | } |
272 | 273 | ||
273 | if (!has_criteria) { | 274 | if (!has_criteria) { |
274 | config->handler_context.current_container = NULL; | 275 | // without criteria, the command acts upon the focused |
275 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 276 | // container |
276 | if (res->status != CMD_SUCCESS) { | 277 | struct sway_seat *seat = config->handler_context.seat; |
277 | free_argv(argc, argv); | 278 | if (!seat) { |
278 | if (results) { | 279 | seat = sway_input_manager_get_default_seat(input_manager); |
279 | free_cmd_results(results); | 280 | } |
281 | if (seat) { | ||
282 | config->handler_context.current_container = seat->focus; | ||
283 | struct cmd_results *res = handler->handle(argc-1, argv+1); | ||
284 | if (res->status != CMD_SUCCESS) { | ||
285 | free_argv(argc, argv); | ||
286 | if (results) { | ||
287 | free_cmd_results(results); | ||
288 | } | ||
289 | results = res; | ||
290 | goto cleanup; | ||
280 | } | 291 | } |
281 | results = res; | 292 | free_cmd_results(res); |
282 | goto cleanup; | ||
283 | } | 293 | } |
284 | free_cmd_results(res); | ||
285 | } else { | 294 | } else { |
286 | wlr_log(L_DEBUG, "@@ running command on containers"); | ||
287 | for (int i = 0; i < containers->length; ++i) { | 295 | for (int i = 0; i < containers->length; ++i) { |
288 | config->handler_context.current_container = containers->items[i]; | 296 | config->handler_context.current_container = containers->items[i]; |
289 | struct cmd_results *res = handler->handle(argc-1, argv+1); | 297 | struct cmd_results *res = handler->handle(argc-1, argv+1); |