summaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2018-09-22 19:51:02 -0500
committerGitHub <[email protected]>2018-09-22 19:51:02 -0500
commit68395f34f686aa1901077505405775ba5bafe6ee (patch)
tree0c3a2cff652b212830efb9d674c1b8d6d305bcac /sway/commands.c
parentae2055dcf1d389b0acefad4c55cb6030731e9c51 (diff)
parentcb66bbea42adeabd7bd87132a66589e14a46940f (diff)
Merge pull request #2688 from RyanDwyer/exec-commands-without-focus
Allow running commands on containers without focusing them
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 07169f1e..5b61f73a 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -237,7 +237,8 @@ static void set_config_node(struct sway_node *node) {
}
}
-struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
+struct cmd_results *execute_command(char *_exec, struct sway_seat *seat,
+ struct sway_container *con) {
// Even though this function will process multiple commands we will only
// return the last error, if any (for now). (Since we have access to an
// error string we could e.g. concatenate all errors there.)
@@ -256,6 +257,15 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
}
}
+ // This is the container or workspace which this command will run on.
+ // Ignored if the command string contains criteria.
+ struct sway_node *node;
+ if (con) {
+ node = &con->node;
+ } else {
+ node = seat_get_focus_inactive(seat, &root->node);
+ }
+
config->handler_context.seat = seat;
head = exec;
@@ -318,9 +328,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
}
if (!config->handler_context.using_criteria) {
- // without criteria, the command acts upon the focused
- // container
- set_config_node(seat_get_focus_inactive(seat, &root->node));
+ set_config_node(node);
struct cmd_results *res = handler->handle(argc-1, argv+1);
if (res->status != CMD_SUCCESS) {
free_argv(argc, argv);