mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
handle_command: Skip commands that has a criteria string.
We can't handle them currently (the criteria needs to e.g. be passed to each command handler which then needs to do the right thing), so it's better to just do nothing than to create unexpected results (because the command was executed on the wrong view). (Before this patch any command list with a criteria string would simply fail to parse, so this is at least a step in the right direction.)
This commit is contained in:
parent
b7e3d05ace
commit
db92920cf9
|
@ -1401,17 +1401,34 @@ struct cmd_results *handle_command(char *_exec) {
|
|||
|
||||
head = exec;
|
||||
do {
|
||||
// Handle criteria
|
||||
// Extract criteria (valid for this command list only).
|
||||
criteria = NULL;
|
||||
if (*head == '[') {
|
||||
++head;
|
||||
criteria = argsep(&head, "]");
|
||||
if (head) {
|
||||
++head;
|
||||
// TODO handle criteria
|
||||
} else {
|
||||
results = cmd_results_new(CMD_INVALID, NULL, "Unmatched [");
|
||||
if (!results) {
|
||||
results = cmd_results_new(CMD_INVALID, criteria, "Unmatched [");
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
// Skip leading whitespace
|
||||
head += strspn(head, whitespace);
|
||||
|
||||
// TODO: it will yield unexpected results to execute commands
|
||||
// (on any view) that where meant for certain views only.
|
||||
if (!results) {
|
||||
int len = strlen(criteria) + strlen(head) + 4;
|
||||
char *tmp = malloc(len);
|
||||
snprintf(tmp, len, "[%s] %s", criteria, head);
|
||||
results = cmd_results_new(CMD_INVALID, tmp,
|
||||
"Can't handle criteria string: Refusing to execute command");
|
||||
free(tmp);
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
// Split command list
|
||||
cmdlist = argsep(&head, ";");
|
||||
|
|
Loading…
Reference in a new issue