mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01:00
ipc: collapse multi-container command results
Match i3's behavior and only return one status response per command, even if it applies to several nodes. Also returns an error if the criteria returns an empty match. Closes #4483
This commit is contained in:
parent
aa9ba58169
commit
a074e0f504
1 changed files with 19 additions and 4 deletions
|
@ -284,17 +284,32 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
} else if (views->length == 0) {
|
||||||
|
list_add(res_list,
|
||||||
|
cmd_results_new(CMD_FAILURE, "No matching node."));
|
||||||
} else {
|
} else {
|
||||||
|
struct cmd_results *fail_res = NULL;
|
||||||
for (int i = 0; i < views->length; ++i) {
|
for (int i = 0; i < views->length; ++i) {
|
||||||
struct sway_view *view = views->items[i];
|
struct sway_view *view = views->items[i];
|
||||||
set_config_node(&view->container->node);
|
set_config_node(&view->container->node);
|
||||||
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
||||||
list_add(res_list, res);
|
if (res->status == CMD_SUCCESS) {
|
||||||
if (res->status == CMD_INVALID) {
|
free_cmd_results(res);
|
||||||
free_argv(argc, argv);
|
} else {
|
||||||
goto cleanup;
|
// last failure will take precedence
|
||||||
|
if (fail_res) {
|
||||||
|
free_cmd_results(fail_res);
|
||||||
|
}
|
||||||
|
fail_res = res;
|
||||||
|
if (res->status == CMD_INVALID) {
|
||||||
|
list_add(res_list, fail_res);
|
||||||
|
free_argv(argc, argv);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
list_add(res_list,
|
||||||
|
fail_res ? fail_res : cmd_results_new(CMD_SUCCESS, NULL));
|
||||||
}
|
}
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
} while(head);
|
} while(head);
|
||||||
|
|
Loading…
Reference in a new issue