aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-10 08:27:52 -0500
committerLibravatar M Stoeckl <code@mstoeckl.com>2019-01-14 07:58:02 -0500
commit6d392150a72ecc3b69fcfb48865f625e2c7b79d6 (patch)
treed475f79c414825f4f3eb6ab0e2d2e28d929f7e71 /sway/commands.c
parentMerge pull request #3418 from RyanDwyer/remove-resize-axis (diff)
downloadsway-6d392150a72ecc3b69fcfb48865f625e2c7b79d6.tar.gz
sway-6d392150a72ecc3b69fcfb48865f625e2c7b79d6.tar.zst
sway-6d392150a72ecc3b69fcfb48865f625e2c7b79d6.zip
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.)
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 1d190e0b..9fae6a35 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -316,7 +316,7 @@ cleanup:
316// be chained together) 316// be chained together)
317// 4) execute_command handles all state internally while config_command has 317// 4) execute_command handles all state internally while config_command has
318// some state handled outside (notably the block mode, in read_config) 318// some state handled outside (notably the block mode, in read_config)
319struct cmd_results *config_command(char *exec) { 319struct cmd_results *config_command(char *exec, char **new_block) {
320 struct cmd_results *results = NULL; 320 struct cmd_results *results = NULL;
321 int argc; 321 int argc;
322 char **argv = split_args(exec, &argc); 322 char **argv = split_args(exec, &argc);
@@ -329,9 +329,8 @@ struct cmd_results *config_command(char *exec) {
329 329
330 // Check for the start of a block 330 // Check for the start of a block
331 if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) { 331 if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) {
332 char *block = join_args(argv, argc - 1); 332 *new_block = join_args(argv, argc - 1);
333 results = cmd_results_new(CMD_BLOCK, block, NULL); 333 results = cmd_results_new(CMD_BLOCK, NULL, NULL);
334 free(block);
335 goto cleanup; 334 goto cleanup;
336 } 335 }
337 336
@@ -509,11 +508,7 @@ struct cmd_results *cmd_results_new(enum cmd_status status,
509 return NULL; 508 return NULL;
510 } 509 }
511 results->status = status; 510 results->status = status;
512 if (input) { 511 // NOTE: `input` argument is unused, remove
513 results->input = strdup(input); // input is the command name
514 } else {
515 results->input = NULL;
516 }
517 if (format) { 512 if (format) {
518 char *error = malloc(256); 513 char *error = malloc(256);
519 va_list args; 514 va_list args;
@@ -530,9 +525,6 @@ struct cmd_results *cmd_results_new(enum cmd_status status,
530} 525}
531 526
532void free_cmd_results(struct cmd_results *results) { 527void free_cmd_results(struct cmd_results *results) {
533 if (results->input) {
534 free(results->input);
535 }
536 if (results->error) { 528 if (results->error) {
537 free(results->error); 529 free(results->error);
538 } 530 }
@@ -552,10 +544,6 @@ char *cmd_results_to_json(list_t *res_list) {
552 json_object_object_add( 544 json_object_object_add(
553 root, "error", json_object_new_string(results->error)); 545 root, "error", json_object_new_string(results->error));
554 } 546 }
555 if (results->input) {
556 json_object_object_add(
557 root, "input", json_object_new_string(results->input));
558 }
559 json_object_array_add(result_array, root); 547 json_object_array_add(result_array, root);
560 } 548 }
561 const char *json = json_object_to_json_string(result_array); 549 const char *json = json_object_to_json_string(result_array);