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 | |
parent | basic command criteria (diff) | |
download | sway-1156523ccf8b45102333cca7d80b3451930b48e8.tar.gz sway-1156523ccf8b45102333cca7d80b3451930b48e8.tar.zst sway-1156523ccf8b45102333cca7d80b3451930b48e8.zip |
run all commands with focused container context
-rw-r--r-- | sway/commands.c | 28 | ||||
-rw-r--r-- | sway/commands/kill.c | 28 |
2 files changed, 28 insertions, 28 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); |
diff --git a/sway/commands/kill.c b/sway/commands/kill.c index f0e3722a..a04c21f3 100644 --- a/sway/commands/kill.c +++ b/sway/commands/kill.c | |||
@@ -1,29 +1,21 @@ | |||
1 | #include <wlr/util/log.h> | ||
1 | #include "sway/input/input-manager.h" | 2 | #include "sway/input/input-manager.h" |
2 | #include "sway/input/seat.h" | 3 | #include "sway/input/seat.h" |
3 | #include "sway/view.h" | 4 | #include "sway/view.h" |
4 | #include "sway/commands.h" | 5 | #include "sway/commands.h" |
5 | 6 | ||
6 | struct cmd_results *cmd_kill(int argc, char **argv) { | 7 | struct cmd_results *cmd_kill(int argc, char **argv) { |
7 | struct sway_seat *seat = config->handler_context.seat; | 8 | if (!config->handler_context.current_container) { |
8 | if (!seat) { | 9 | wlr_log(L_ERROR, "cmd_kill called without container context"); |
9 | seat = sway_input_manager_get_default_seat(input_manager); | 10 | return cmd_results_new(CMD_INVALID, NULL, |
11 | "cmd_kill called without container context " | ||
12 | "(this is a bug in sway)"); | ||
10 | } | 13 | } |
14 | // TODO close arbitrary containers without a view | ||
15 | struct sway_view *view = | ||
16 | config->handler_context.current_container->sway_view; | ||
11 | 17 | ||
12 | // TODO context for arbitrary sway containers (when we get criteria | 18 | if (view && view->iface.close) { |
13 | // working) will make seat context not explicitly required | ||
14 | if (!seat) { | ||
15 | return cmd_results_new(CMD_FAILURE, NULL, "no seat context given"); | ||
16 | } | ||
17 | |||
18 | struct sway_view *view = NULL; | ||
19 | |||
20 | if (config->handler_context.current_container) { | ||
21 | view = config->handler_context.current_container->sway_view; | ||
22 | } else { | ||
23 | view = seat->focus->sway_view; | ||
24 | } | ||
25 | |||
26 | if (view->iface.close) { | ||
27 | view->iface.close(view); | 19 | view->iface.close(view); |
28 | } | 20 | } |
29 | 21 | ||