mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 09:21:28 +00:00
Remove 'input' field of IPC command return json
This field is not in i3 and provides imprecise and redundant information. (Specifically, when swaymsg is given a list of commands, the IPC return array already indicates precisely which number command failed; knowing the name of the command is not useful when multiple commands of the same type are provided.)
This commit is contained in:
parent
64ef936673
commit
6d392150a7
|
@ -31,7 +31,6 @@ enum cmd_status {
|
|||
*/
|
||||
struct cmd_results {
|
||||
enum cmd_status status;
|
||||
char *input;
|
||||
/**
|
||||
* Human friendly error message, or NULL on success
|
||||
*/
|
||||
|
@ -63,7 +62,7 @@ list_t *execute_command(char *command, struct sway_seat *seat,
|
|||
*
|
||||
* Do not use this under normal conditions.
|
||||
*/
|
||||
struct cmd_results *config_command(char *command);
|
||||
struct cmd_results *config_command(char *command, char **new_block);
|
||||
/**
|
||||
* Parse and handle a sub command
|
||||
*/
|
||||
|
|
|
@ -316,7 +316,7 @@ cleanup:
|
|||
// be chained together)
|
||||
// 4) execute_command handles all state internally while config_command has
|
||||
// some state handled outside (notably the block mode, in read_config)
|
||||
struct cmd_results *config_command(char *exec) {
|
||||
struct cmd_results *config_command(char *exec, char **new_block) {
|
||||
struct cmd_results *results = NULL;
|
||||
int argc;
|
||||
char **argv = split_args(exec, &argc);
|
||||
|
@ -329,9 +329,8 @@ struct cmd_results *config_command(char *exec) {
|
|||
|
||||
// Check for the start of a block
|
||||
if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) {
|
||||
char *block = join_args(argv, argc - 1);
|
||||
results = cmd_results_new(CMD_BLOCK, block, NULL);
|
||||
free(block);
|
||||
*new_block = join_args(argv, argc - 1);
|
||||
results = cmd_results_new(CMD_BLOCK, NULL, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -509,11 +508,7 @@ struct cmd_results *cmd_results_new(enum cmd_status status,
|
|||
return NULL;
|
||||
}
|
||||
results->status = status;
|
||||
if (input) {
|
||||
results->input = strdup(input); // input is the command name
|
||||
} else {
|
||||
results->input = NULL;
|
||||
}
|
||||
// NOTE: `input` argument is unused, remove
|
||||
if (format) {
|
||||
char *error = malloc(256);
|
||||
va_list args;
|
||||
|
@ -530,9 +525,6 @@ struct cmd_results *cmd_results_new(enum cmd_status status,
|
|||
}
|
||||
|
||||
void free_cmd_results(struct cmd_results *results) {
|
||||
if (results->input) {
|
||||
free(results->input);
|
||||
}
|
||||
if (results->error) {
|
||||
free(results->error);
|
||||
}
|
||||
|
@ -552,10 +544,6 @@ char *cmd_results_to_json(list_t *res_list) {
|
|||
json_object_object_add(
|
||||
root, "error", json_object_new_string(results->error));
|
||||
}
|
||||
if (results->input) {
|
||||
json_object_object_add(
|
||||
root, "input", json_object_new_string(results->input));
|
||||
}
|
||||
json_object_array_add(result_array, root);
|
||||
}
|
||||
const char *json = json_object_to_json_string(result_array);
|
||||
|
|
|
@ -710,11 +710,12 @@ bool read_config(FILE *file, struct sway_config *config,
|
|||
config->current_config_line_number = line_number;
|
||||
config->current_config_line = line;
|
||||
struct cmd_results *res;
|
||||
char *new_block = NULL;
|
||||
if (block && strcmp(block, "<commands>") == 0) {
|
||||
// Special case
|
||||
res = config_commands_command(expanded);
|
||||
} else {
|
||||
res = config_command(expanded);
|
||||
res = config_command(expanded, &new_block);
|
||||
}
|
||||
switch(res->status) {
|
||||
case CMD_FAILURE:
|
||||
|
@ -740,9 +741,9 @@ bool read_config(FILE *file, struct sway_config *config,
|
|||
break;
|
||||
|
||||
case CMD_BLOCK:
|
||||
wlr_log(WLR_DEBUG, "Entering block '%s'", res->input);
|
||||
list_insert(stack, 0, strdup(res->input));
|
||||
if (strcmp(res->input, "bar") == 0) {
|
||||
wlr_log(WLR_DEBUG, "Entering block '%s'", new_block);
|
||||
list_insert(stack, 0, strdup(new_block));
|
||||
if (strcmp(new_block, "bar") == 0) {
|
||||
config->current_bar = NULL;
|
||||
}
|
||||
break;
|
||||
|
@ -764,6 +765,7 @@ bool read_config(FILE *file, struct sway_config *config,
|
|||
sizeof(config->handler_context));
|
||||
default:;
|
||||
}
|
||||
free(new_block);
|
||||
free(expanded);
|
||||
free_cmd_results(res);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue