aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 07169f1e..03761c52 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -55,22 +55,6 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type
return error;
}
-void apply_input_config(struct input_config *input) {
- int i;
- i = list_seq_find(config->input_configs, input_identifier_cmp, input->identifier);
- if (i >= 0) {
- // merge existing config
- struct input_config *ic = config->input_configs->items[i];
- merge_input_config(ic, input);
- free_input_config(input);
- input = ic;
- } else {
- list_add(config->input_configs, input);
- }
-
- input_manager_apply_input_config(input_manager, input);
-}
-
void apply_seat_config(struct seat_config *seat_config) {
int i;
i = list_seq_find(config->seat_configs, seat_name_cmp, seat_config->name);
@@ -237,7 +221,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 +241,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 +312,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);
@@ -399,14 +391,12 @@ struct cmd_results *config_command(char *exec) {
// Var replacement, for all but first argument of set
// TODO commands
for (i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
+ if (*argv[i] == '\"' || *argv[i] == '\'') {
+ strip_quotes(argv[i]);
+ }
argv[i] = do_var_replacement(argv[i]);
unescape_string(argv[i]);
}
- // Strip quotes for first argument.
- // TODO This part needs to be handled much better
- if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
- strip_quotes(argv[1]);
- }
if (handler->handle) {
results = handler->handle(argc-1, argv+1);
} else {
@@ -430,11 +420,6 @@ struct cmd_results *config_subcommand(char **argv, int argc,
char *input = argv[0] ? argv[0] : "(empty)";
return cmd_results_new(CMD_INVALID, input, "Unknown/invalid command");
}
- // Strip quotes for first argument.
- // TODO This part needs to be handled much better
- if (argc > 1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
- strip_quotes(argv[1]);
- }
if (handler->handle) {
return handler->handle(argc - 1, argv + 1);
}