diff options
-rw-r--r-- | include/sway/commands.h | 3 | ||||
-rw-r--r-- | sway/commands.c | 11 | ||||
-rw-r--r-- | sway/commands/assign.c | 2 | ||||
-rw-r--r-- | sway/commands/bar/bind.c | 2 | ||||
-rw-r--r-- | sway/commands/bar/tray_bind.c | 2 | ||||
-rw-r--r-- | sway/commands/bind.c | 13 | ||||
-rw-r--r-- | sway/commands/floating_minmax_size.c | 6 | ||||
-rw-r--r-- | sway/commands/for_window.c | 2 | ||||
-rw-r--r-- | sway/commands/hide_edge_borders.c | 4 | ||||
-rw-r--r-- | sway/commands/input/map_to_region.c | 2 | ||||
-rw-r--r-- | sway/commands/input/scroll_button.c | 2 | ||||
-rw-r--r-- | sway/commands/layout.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 24 | ||||
-rw-r--r-- | sway/commands/no_focus.c | 2 | ||||
-rw-r--r-- | sway/commands/rename.c | 4 | ||||
-rw-r--r-- | sway/commands/resize.c | 18 | ||||
-rw-r--r-- | sway/commands/seat/cursor.c | 10 | ||||
-rw-r--r-- | sway/commands/swap.c | 4 | ||||
-rw-r--r-- | sway/commands/workspace.c | 8 |
19 files changed, 63 insertions, 58 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index fc6ce22e..3212c2cf 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <wlr/util/edges.h> | 4 | #include <wlr/util/edges.h> |
5 | #include "config.h" | 5 | #include "config.h" |
6 | #include "stringop.h" | ||
6 | 7 | ||
7 | struct sway_container; | 8 | struct sway_container; |
8 | 9 | ||
@@ -76,7 +77,7 @@ struct cmd_results *config_commands_command(char *exec); | |||
76 | /** | 77 | /** |
77 | * Allocates a cmd_results object. | 78 | * Allocates a cmd_results object. |
78 | */ | 79 | */ |
79 | struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...); | 80 | struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...) _SWAY_ATTRIB_PRINTF(2, 3); |
80 | /** | 81 | /** |
81 | * Frees a cmd_results object. | 82 | * Frees a cmd_results object. |
82 | */ | 83 | */ |
diff --git a/sway/commands.c b/sway/commands.c index 28e9d8d2..0ea44129 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -381,10 +381,13 @@ struct cmd_results *config_command(char *exec, char **new_block) { | |||
381 | sway_log(SWAY_INFO, "Config command: %s", exec); | 381 | sway_log(SWAY_INFO, "Config command: %s", exec); |
382 | const struct cmd_handler *handler = find_core_handler(argv[0]); | 382 | const struct cmd_handler *handler = find_core_handler(argv[0]); |
383 | if (!handler || !handler->handle) { | 383 | if (!handler || !handler->handle) { |
384 | const char *error = handler | 384 | if (handler) { |
385 | ? "Command '%s' is shimmed, but unimplemented" | 385 | results = cmd_results_new(CMD_INVALID, |
386 | : "Unknown/invalid command '%s'"; | 386 | "Command '%s' is shimmed, but unimplemented", argv[0]); |
387 | results = cmd_results_new(CMD_INVALID, error, argv[0]); | 387 | } else { |
388 | results = cmd_results_new(CMD_INVALID, | ||
389 | "Unknown/invalid command '%s'", argv[0]); | ||
390 | } | ||
388 | goto cleanup; | 391 | goto cleanup; |
389 | } | 392 | } |
390 | 393 | ||
diff --git a/sway/commands/assign.c b/sway/commands/assign.c index 976bc3cc..f7d911f7 100644 --- a/sway/commands/assign.c +++ b/sway/commands/assign.c | |||
@@ -17,7 +17,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) { | |||
17 | char *err_str = NULL; | 17 | char *err_str = NULL; |
18 | struct criteria *criteria = criteria_parse(argv[0], &err_str); | 18 | struct criteria *criteria = criteria_parse(argv[0], &err_str); |
19 | if (!criteria) { | 19 | if (!criteria) { |
20 | error = cmd_results_new(CMD_INVALID, err_str); | 20 | error = cmd_results_new(CMD_INVALID, "%s", err_str); |
21 | free(err_str); | 21 | free(err_str); |
22 | return error; | 22 | return error; |
23 | } | 23 | } |
diff --git a/sway/commands/bar/bind.c b/sway/commands/bar/bind.c index b4b5bc45..8a837e3f 100644 --- a/sway/commands/bar/bind.c +++ b/sway/commands/bar/bind.c | |||
@@ -96,7 +96,7 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code, | |||
96 | } | 96 | } |
97 | if (message) { | 97 | if (message) { |
98 | free_bar_binding(binding); | 98 | free_bar_binding(binding); |
99 | error = cmd_results_new(CMD_INVALID, message); | 99 | error = cmd_results_new(CMD_INVALID, "%s", message); |
100 | free(message); | 100 | free(message); |
101 | return error; | 101 | return error; |
102 | } else if (!binding->button) { | 102 | } else if (!binding->button) { |
diff --git a/sway/commands/bar/tray_bind.c b/sway/commands/bar/tray_bind.c index 243834ba..3dc9bc4c 100644 --- a/sway/commands/bar/tray_bind.c +++ b/sway/commands/bar/tray_bind.c | |||
@@ -26,7 +26,7 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) { | |||
26 | } | 26 | } |
27 | if (message) { | 27 | if (message) { |
28 | free(binding); | 28 | free(binding); |
29 | error = cmd_results_new(CMD_INVALID, message); | 29 | error = cmd_results_new(CMD_INVALID, "%s", message); |
30 | free(message); | 30 | free(message); |
31 | return error; | 31 | return error; |
32 | } else if (!binding->button) { | 32 | } else if (!binding->button) { |
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index c0b383db..979e178f 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -127,7 +127,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key, | |||
127 | if (!button) { | 127 | if (!button) { |
128 | if (message) { | 128 | if (message) { |
129 | struct cmd_results *error = | 129 | struct cmd_results *error = |
130 | cmd_results_new(CMD_INVALID, message); | 130 | cmd_results_new(CMD_INVALID, "%s", message); |
131 | free(message); | 131 | free(message); |
132 | return error; | 132 | return error; |
133 | } else { | 133 | } else { |
@@ -143,7 +143,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key, | |||
143 | if (!button) { | 143 | if (!button) { |
144 | if (message) { | 144 | if (message) { |
145 | struct cmd_results *error = | 145 | struct cmd_results *error = |
146 | cmd_results_new(CMD_INVALID, message); | 146 | cmd_results_new(CMD_INVALID, "%s", message); |
147 | free(message); | 147 | free(message); |
148 | return error; | 148 | return error; |
149 | } else { | 149 | } else { |
@@ -182,7 +182,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key, | |||
182 | uint32_t button = get_mouse_bindsym(name, &message); | 182 | uint32_t button = get_mouse_bindsym(name, &message); |
183 | if (message) { | 183 | if (message) { |
184 | struct cmd_results *error = | 184 | struct cmd_results *error = |
185 | cmd_results_new(CMD_INVALID, message); | 185 | cmd_results_new(CMD_INVALID, "%s", message); |
186 | free(message); | 186 | free(message); |
187 | return error; | 187 | return error; |
188 | } else if (button) { | 188 | } else if (button) { |
@@ -539,7 +539,7 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv, | |||
539 | free_switch_binding(binding); | 539 | free_switch_binding(binding); |
540 | return cmd_results_new(CMD_FAILURE, | 540 | return cmd_results_new(CMD_FAILURE, |
541 | "Invalid %s command (expected binding with the form " | 541 | "Invalid %s command (expected binding with the form " |
542 | "<switch>:<state>)", bindtype, argc); | 542 | "<switch>:<state>)", bindtype); |
543 | } | 543 | } |
544 | if (strcmp(split->items[0], "tablet") == 0) { | 544 | if (strcmp(split->items[0], "tablet") == 0) { |
545 | binding->type = WLR_SWITCH_TYPE_TABLET_MODE; | 545 | binding->type = WLR_SWITCH_TYPE_TABLET_MODE; |
@@ -549,7 +549,8 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv, | |||
549 | free_switch_binding(binding); | 549 | free_switch_binding(binding); |
550 | return cmd_results_new(CMD_FAILURE, | 550 | return cmd_results_new(CMD_FAILURE, |
551 | "Invalid %s command (expected switch binding: " | 551 | "Invalid %s command (expected switch binding: " |
552 | "unknown switch %s)", bindtype, split->items[0]); | 552 | "unknown switch %s)", bindtype, |
553 | (const char *)split->items[0]); | ||
553 | } | 554 | } |
554 | if (strcmp(split->items[1], "on") == 0) { | 555 | if (strcmp(split->items[1], "on") == 0) { |
555 | binding->trigger = SWAY_SWITCH_TRIGGER_ON; | 556 | binding->trigger = SWAY_SWITCH_TRIGGER_ON; |
@@ -562,7 +563,7 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv, | |||
562 | return cmd_results_new(CMD_FAILURE, | 563 | return cmd_results_new(CMD_FAILURE, |
563 | "Invalid %s command " | 564 | "Invalid %s command " |
564 | "(expected switch state: unknown state %s)", | 565 | "(expected switch state: unknown state %s)", |
565 | bindtype, split->items[1]); | 566 | bindtype, (const char *)split->items[1]); |
566 | } | 567 | } |
567 | list_free_items_and_destroy(split); | 568 | list_free_items_and_destroy(split); |
568 | 569 | ||
diff --git a/sway/commands/floating_minmax_size.c b/sway/commands/floating_minmax_size.c index 1c28c536..e8c24ace 100644 --- a/sway/commands/floating_minmax_size.c +++ b/sway/commands/floating_minmax_size.c | |||
@@ -23,16 +23,16 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, | |||
23 | char *err; | 23 | char *err; |
24 | int width = (int)strtol(argv[0], &err, 10); | 24 | int width = (int)strtol(argv[0], &err, 10); |
25 | if (*err) { | 25 | if (*err) { |
26 | return cmd_results_new(CMD_INVALID, usage); | 26 | return cmd_results_new(CMD_INVALID, "%s", usage); |
27 | } | 27 | } |
28 | 28 | ||
29 | if (strcmp(argv[1], "x") != 0) { | 29 | if (strcmp(argv[1], "x") != 0) { |
30 | return cmd_results_new(CMD_INVALID, usage); | 30 | return cmd_results_new(CMD_INVALID, "%s", usage); |
31 | } | 31 | } |
32 | 32 | ||
33 | int height = (int)strtol(argv[2], &err, 10); | 33 | int height = (int)strtol(argv[2], &err, 10); |
34 | if (*err) { | 34 | if (*err) { |
35 | return cmd_results_new(CMD_INVALID, usage); | 35 | return cmd_results_new(CMD_INVALID, "%s", usage); |
36 | } | 36 | } |
37 | 37 | ||
38 | *config_width = width; | 38 | *config_width = width; |
diff --git a/sway/commands/for_window.c b/sway/commands/for_window.c index ee9f4647..905e6776 100644 --- a/sway/commands/for_window.c +++ b/sway/commands/for_window.c | |||
@@ -14,7 +14,7 @@ struct cmd_results *cmd_for_window(int argc, char **argv) { | |||
14 | char *err_str = NULL; | 14 | char *err_str = NULL; |
15 | struct criteria *criteria = criteria_parse(argv[0], &err_str); | 15 | struct criteria *criteria = criteria_parse(argv[0], &err_str); |
16 | if (!criteria) { | 16 | if (!criteria) { |
17 | error = cmd_results_new(CMD_INVALID, err_str); | 17 | error = cmd_results_new(CMD_INVALID, "%s", err_str); |
18 | free(err_str); | 18 | free(err_str); |
19 | return error; | 19 | return error; |
20 | } | 20 | } |
diff --git a/sway/commands/hide_edge_borders.c b/sway/commands/hide_edge_borders.c index 9a1d8445..43bd6dc8 100644 --- a/sway/commands/hide_edge_borders.c +++ b/sway/commands/hide_edge_borders.c | |||
@@ -20,7 +20,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { | |||
20 | } | 20 | } |
21 | 21 | ||
22 | if (!argc) { | 22 | if (!argc) { |
23 | return cmd_results_new(CMD_INVALID, expected_syntax); | 23 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
24 | } | 24 | } |
25 | 25 | ||
26 | if (strcmp(argv[0], "none") == 0) { | 26 | if (strcmp(argv[0], "none") == 0) { |
@@ -38,7 +38,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { | |||
38 | config->hide_edge_borders = E_NONE; | 38 | config->hide_edge_borders = E_NONE; |
39 | config->hide_edge_borders_smart = ESMART_NO_GAPS; | 39 | config->hide_edge_borders_smart = ESMART_NO_GAPS; |
40 | } else { | 40 | } else { |
41 | return cmd_results_new(CMD_INVALID, expected_syntax); | 41 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
42 | } | 42 | } |
43 | config->hide_lone_tab = hide_lone_tab; | 43 | config->hide_lone_tab = hide_lone_tab; |
44 | 44 | ||
diff --git a/sway/commands/input/map_to_region.c b/sway/commands/input/map_to_region.c index 284b57d0..ad535db2 100644 --- a/sway/commands/input/map_to_region.c +++ b/sway/commands/input/map_to_region.c | |||
@@ -49,5 +49,5 @@ struct cmd_results *input_cmd_map_to_region(int argc, char **argv) { | |||
49 | error: | 49 | error: |
50 | free(ic->mapped_to_region); | 50 | free(ic->mapped_to_region); |
51 | ic->mapped_to_region = NULL; | 51 | ic->mapped_to_region = NULL; |
52 | return cmd_results_new(CMD_FAILURE, errstr); | 52 | return cmd_results_new(CMD_FAILURE, "%s", errstr); |
53 | } | 53 | } |
diff --git a/sway/commands/input/scroll_button.c b/sway/commands/input/scroll_button.c index 6b331419..81f69a6d 100644 --- a/sway/commands/input/scroll_button.c +++ b/sway/commands/input/scroll_button.c | |||
@@ -21,7 +21,7 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) { | |||
21 | char *message = NULL; | 21 | char *message = NULL; |
22 | uint32_t button = get_mouse_button(*argv, &message); | 22 | uint32_t button = get_mouse_button(*argv, &message); |
23 | if (message) { | 23 | if (message) { |
24 | error = cmd_results_new(CMD_INVALID, message); | 24 | error = cmd_results_new(CMD_INVALID, "%s", message); |
25 | free(message); | 25 | free(message); |
26 | return error; | 26 | return error; |
27 | } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN | 27 | } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 2ba61b38..12ce4839 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -153,7 +153,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
153 | workspace->output); | 153 | workspace->output); |
154 | } | 154 | } |
155 | if (new_layout == L_NONE) { | 155 | if (new_layout == L_NONE) { |
156 | return cmd_results_new(CMD_INVALID, expected_syntax); | 156 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
157 | } | 157 | } |
158 | if (new_layout != old_layout) { | 158 | if (new_layout != old_layout) { |
159 | if (container) { | 159 | if (container) { |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 9e40a3b4..69ed06c0 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -470,7 +470,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth, | |||
470 | if (strcasecmp(argv[1], "number") == 0) { | 470 | if (strcasecmp(argv[1], "number") == 0) { |
471 | // move [window|container] [to] "workspace number x" | 471 | // move [window|container] [to] "workspace number x" |
472 | if (argc < 3) { | 472 | if (argc < 3) { |
473 | return cmd_results_new(CMD_INVALID, expected_syntax); | 473 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
474 | } | 474 | } |
475 | if (!isdigit(argv[2][0])) { | 475 | if (!isdigit(argv[2][0])) { |
476 | return cmd_results_new(CMD_INVALID, | 476 | return cmd_results_new(CMD_INVALID, |
@@ -530,7 +530,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth, | |||
530 | } | 530 | } |
531 | destination = &dest_con->node; | 531 | destination = &dest_con->node; |
532 | } else { | 532 | } else { |
533 | return cmd_results_new(CMD_INVALID, expected_syntax); | 533 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
534 | } | 534 | } |
535 | 535 | ||
536 | if (destination->type == N_CONTAINER && | 536 | if (destination->type == N_CONTAINER && |
@@ -829,7 +829,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) { | |||
829 | } | 829 | } |
830 | 830 | ||
831 | if (!argc) { | 831 | if (!argc) { |
832 | return cmd_results_new(CMD_INVALID, expected_position_syntax); | 832 | return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax); |
833 | } | 833 | } |
834 | 834 | ||
835 | bool absolute = false; | 835 | bool absolute = false; |
@@ -839,19 +839,19 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) { | |||
839 | ++argv; | 839 | ++argv; |
840 | } | 840 | } |
841 | if (!argc) { | 841 | if (!argc) { |
842 | return cmd_results_new(CMD_INVALID, expected_position_syntax); | 842 | return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax); |
843 | } | 843 | } |
844 | if (strcmp(argv[0], "position") == 0) { | 844 | if (strcmp(argv[0], "position") == 0) { |
845 | --argc; | 845 | --argc; |
846 | ++argv; | 846 | ++argv; |
847 | } | 847 | } |
848 | if (!argc) { | 848 | if (!argc) { |
849 | return cmd_results_new(CMD_INVALID, expected_position_syntax); | 849 | return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax); |
850 | } | 850 | } |
851 | if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 || | 851 | if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 || |
852 | strcmp(argv[0], "pointer") == 0) { | 852 | strcmp(argv[0], "pointer") == 0) { |
853 | if (absolute) { | 853 | if (absolute) { |
854 | return cmd_results_new(CMD_INVALID, expected_position_syntax); | 854 | return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax); |
855 | } | 855 | } |
856 | return cmd_move_to_position_pointer(container); | 856 | return cmd_move_to_position_pointer(container); |
857 | } else if (strcmp(argv[0], "center") == 0) { | 857 | } else if (strcmp(argv[0], "center") == 0) { |
@@ -873,7 +873,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) { | |||
873 | } | 873 | } |
874 | 874 | ||
875 | if (argc < 2) { | 875 | if (argc < 2) { |
876 | return cmd_results_new(CMD_FAILURE, expected_position_syntax); | 876 | return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax); |
877 | } | 877 | } |
878 | 878 | ||
879 | struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; | 879 | struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; |
@@ -886,7 +886,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) { | |||
886 | } | 886 | } |
887 | 887 | ||
888 | if (argc < 1) { | 888 | if (argc < 1) { |
889 | return cmd_results_new(CMD_FAILURE, expected_position_syntax); | 889 | return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax); |
890 | } | 890 | } |
891 | 891 | ||
892 | struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; | 892 | struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; |
@@ -895,7 +895,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) { | |||
895 | argc -= num_consumed_args; | 895 | argc -= num_consumed_args; |
896 | argv += num_consumed_args; | 896 | argv += num_consumed_args; |
897 | if (argc > 0) { | 897 | if (argc > 0) { |
898 | return cmd_results_new(CMD_INVALID, expected_position_syntax); | 898 | return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax); |
899 | } | 899 | } |
900 | if (ly.unit == MOVEMENT_UNIT_INVALID) { | 900 | if (ly.unit == MOVEMENT_UNIT_INVALID) { |
901 | return cmd_results_new(CMD_INVALID, "Invalid y position specified"); | 901 | return cmd_results_new(CMD_INVALID, "Invalid y position specified"); |
@@ -1041,13 +1041,13 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | if (!argc) { | 1043 | if (!argc) { |
1044 | return cmd_results_new(CMD_INVALID, expected_full_syntax); | 1044 | return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | // Only `move [window|container] [to] workspace` supports | 1047 | // Only `move [window|container] [to] workspace` supports |
1048 | // `--no-auto-back-and-forth` so treat others as invalid syntax | 1048 | // `--no-auto-back-and-forth` so treat others as invalid syntax |
1049 | if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) { | 1049 | if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) { |
1050 | return cmd_results_new(CMD_INVALID, expected_full_syntax); | 1050 | return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax); |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | if (strcasecmp(argv[0], "workspace") == 0 || | 1053 | if (strcasecmp(argv[0], "workspace") == 0 || |
@@ -1061,5 +1061,5 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
1061 | strcasecmp(argv[1], "position") == 0)) { | 1061 | strcasecmp(argv[1], "position") == 0)) { |
1062 | return cmd_move_to_position(argc, argv); | 1062 | return cmd_move_to_position(argc, argv); |
1063 | } | 1063 | } |
1064 | return cmd_results_new(CMD_INVALID, expected_full_syntax); | 1064 | return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax); |
1065 | } | 1065 | } |
diff --git a/sway/commands/no_focus.c b/sway/commands/no_focus.c index 2001e04f..ccfdec82 100644 --- a/sway/commands/no_focus.c +++ b/sway/commands/no_focus.c | |||
@@ -13,7 +13,7 @@ struct cmd_results *cmd_no_focus(int argc, char **argv) { | |||
13 | char *err_str = NULL; | 13 | char *err_str = NULL; |
14 | struct criteria *criteria = criteria_parse(argv[0], &err_str); | 14 | struct criteria *criteria = criteria_parse(argv[0], &err_str); |
15 | if (!criteria) { | 15 | if (!criteria) { |
16 | error = cmd_results_new(CMD_INVALID, err_str); | 16 | error = cmd_results_new(CMD_INVALID, "%s", err_str); |
17 | free(err_str); | 17 | free(err_str); |
18 | return error; | 18 | return error; |
19 | } | 19 | } |
diff --git a/sway/commands/rename.c b/sway/commands/rename.c index 60a66d58..0d36cc21 100644 --- a/sway/commands/rename.c +++ b/sway/commands/rename.c | |||
@@ -26,7 +26,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) { | |||
26 | "Can't run this command while there's no outputs connected."); | 26 | "Can't run this command while there's no outputs connected."); |
27 | } | 27 | } |
28 | if (strcasecmp(argv[0], "workspace") != 0) { | 28 | if (strcasecmp(argv[0], "workspace") != 0) { |
29 | return cmd_results_new(CMD_INVALID, expected_syntax); | 29 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
30 | } | 30 | } |
31 | 31 | ||
32 | int argn = 1; | 32 | int argn = 1; |
@@ -65,7 +65,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) { | |||
65 | ++argn; // move past "to" | 65 | ++argn; // move past "to" |
66 | 66 | ||
67 | if (argn >= argc) { | 67 | if (argn >= argc) { |
68 | return cmd_results_new(CMD_INVALID, expected_syntax); | 68 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
69 | } | 69 | } |
70 | 70 | ||
71 | char *new_name = join_args(argv + argn, argc - argn); | 71 | char *new_name = join_args(argv + argn, argc - argn); |
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 425069de..e69e5506 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -415,7 +415,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { | |||
415 | argc -= num_consumed_args; | 415 | argc -= num_consumed_args; |
416 | argv += num_consumed_args; | 416 | argv += num_consumed_args; |
417 | if (width.unit == MOVEMENT_UNIT_INVALID) { | 417 | if (width.unit == MOVEMENT_UNIT_INVALID) { |
418 | return cmd_results_new(CMD_INVALID, usage); | 418 | return cmd_results_new(CMD_INVALID, "%s", usage); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
@@ -427,10 +427,10 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { | |||
427 | } | 427 | } |
428 | int num_consumed_args = parse_movement_amount(argc, argv, &height); | 428 | int num_consumed_args = parse_movement_amount(argc, argv, &height); |
429 | if (argc > num_consumed_args) { | 429 | if (argc > num_consumed_args) { |
430 | return cmd_results_new(CMD_INVALID, usage); | 430 | return cmd_results_new(CMD_INVALID, "%s", usage); |
431 | } | 431 | } |
432 | if (width.unit == MOVEMENT_UNIT_INVALID) { | 432 | if (width.unit == MOVEMENT_UNIT_INVALID) { |
433 | return cmd_results_new(CMD_INVALID, usage); | 433 | return cmd_results_new(CMD_INVALID, "%s", usage); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
@@ -462,7 +462,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
462 | "[<amount> px|ppt [or <amount> px|ppt]]'"; | 462 | "[<amount> px|ppt [or <amount> px|ppt]]'"; |
463 | uint32_t axis = parse_resize_axis(*argv); | 463 | uint32_t axis = parse_resize_axis(*argv); |
464 | if (axis == WLR_EDGE_NONE) { | 464 | if (axis == WLR_EDGE_NONE) { |
465 | return cmd_results_new(CMD_INVALID, usage); | 465 | return cmd_results_new(CMD_INVALID, "%s", usage); |
466 | } | 466 | } |
467 | --argc; ++argv; | 467 | --argc; ++argv; |
468 | 468 | ||
@@ -473,7 +473,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
473 | argc -= num_consumed_args; | 473 | argc -= num_consumed_args; |
474 | argv += num_consumed_args; | 474 | argv += num_consumed_args; |
475 | if (first_amount.unit == MOVEMENT_UNIT_INVALID) { | 475 | if (first_amount.unit == MOVEMENT_UNIT_INVALID) { |
476 | return cmd_results_new(CMD_INVALID, usage); | 476 | return cmd_results_new(CMD_INVALID, "%s", usage); |
477 | } | 477 | } |
478 | } else { | 478 | } else { |
479 | first_amount.amount = 10; | 479 | first_amount.amount = 10; |
@@ -483,7 +483,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
483 | // "or" | 483 | // "or" |
484 | if (argc) { | 484 | if (argc) { |
485 | if (strcmp(*argv, "or") != 0) { | 485 | if (strcmp(*argv, "or") != 0) { |
486 | return cmd_results_new(CMD_INVALID, usage); | 486 | return cmd_results_new(CMD_INVALID, "%s", usage); |
487 | } | 487 | } |
488 | --argc; ++argv; | 488 | --argc; ++argv; |
489 | } | 489 | } |
@@ -493,10 +493,10 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, | |||
493 | if (argc) { | 493 | if (argc) { |
494 | int num_consumed_args = parse_movement_amount(argc, argv, &second_amount); | 494 | int num_consumed_args = parse_movement_amount(argc, argv, &second_amount); |
495 | if (argc > num_consumed_args) { | 495 | if (argc > num_consumed_args) { |
496 | return cmd_results_new(CMD_INVALID, usage); | 496 | return cmd_results_new(CMD_INVALID, "%s", usage); |
497 | } | 497 | } |
498 | if (second_amount.unit == MOVEMENT_UNIT_INVALID) { | 498 | if (second_amount.unit == MOVEMENT_UNIT_INVALID) { |
499 | return cmd_results_new(CMD_INVALID, usage); | 499 | return cmd_results_new(CMD_INVALID, "%s", usage); |
500 | } | 500 | } |
501 | } else { | 501 | } else { |
502 | second_amount.amount = 0; | 502 | second_amount.amount = 0; |
@@ -566,5 +566,5 @@ struct cmd_results *cmd_resize(int argc, char **argv) { | |||
566 | const char usage[] = "Expected 'resize <shrink|grow> " | 566 | const char usage[] = "Expected 'resize <shrink|grow> " |
567 | "<width|height|up|down|left|right> [<amount>] [px|ppt]'"; | 567 | "<width|height|up|down|left|right> [<amount>] [px|ppt]'"; |
568 | 568 | ||
569 | return cmd_results_new(CMD_INVALID, usage); | 569 | return cmd_results_new(CMD_INVALID, "%s", usage); |
570 | } | 570 | } |
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 504a9f5e..5a8a3bc8 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c | |||
@@ -18,7 +18,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
18 | int argc, char **argv) { | 18 | int argc, char **argv) { |
19 | if (strcasecmp(argv[0], "move") == 0) { | 19 | if (strcasecmp(argv[0], "move") == 0) { |
20 | if (argc < 3) { | 20 | if (argc < 3) { |
21 | return cmd_results_new(CMD_INVALID, expected_syntax); | 21 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
22 | } | 22 | } |
23 | int delta_x = strtol(argv[1], NULL, 10); | 23 | int delta_x = strtol(argv[1], NULL, 10); |
24 | int delta_y = strtol(argv[2], NULL, 10); | 24 | int delta_y = strtol(argv[2], NULL, 10); |
@@ -27,7 +27,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
27 | wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); | 27 | wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); |
28 | } else if (strcasecmp(argv[0], "set") == 0) { | 28 | } else if (strcasecmp(argv[0], "set") == 0) { |
29 | if (argc < 3) { | 29 | if (argc < 3) { |
30 | return cmd_results_new(CMD_INVALID, expected_syntax); | 30 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
31 | } | 31 | } |
32 | // map absolute coords (0..1,0..1) to root container coords | 32 | // map absolute coords (0..1,0..1) to root container coords |
33 | float x = strtof(argv[1], NULL) / root->width; | 33 | float x = strtof(argv[1], NULL) / root->width; |
@@ -37,7 +37,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
37 | wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); | 37 | wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); |
38 | } else { | 38 | } else { |
39 | if (argc < 2) { | 39 | if (argc < 2) { |
40 | return cmd_results_new(CMD_INVALID, expected_syntax); | 40 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
41 | } | 41 | } |
42 | struct cmd_results *error = NULL; | 42 | struct cmd_results *error = NULL; |
43 | if ((error = press_or_release(cursor, argv[0], argv[1]))) { | 43 | if ((error = press_or_release(cursor, argv[0], argv[1]))) { |
@@ -92,14 +92,14 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor, | |||
92 | } else if (strcasecmp(action, "release") == 0) { | 92 | } else if (strcasecmp(action, "release") == 0) { |
93 | state = WLR_BUTTON_RELEASED; | 93 | state = WLR_BUTTON_RELEASED; |
94 | } else { | 94 | } else { |
95 | return cmd_results_new(CMD_INVALID, expected_syntax); | 95 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
96 | } | 96 | } |
97 | 97 | ||
98 | char *message = NULL; | 98 | char *message = NULL; |
99 | button = get_mouse_button(button_str, &message); | 99 | button = get_mouse_button(button_str, &message); |
100 | if (message) { | 100 | if (message) { |
101 | struct cmd_results *error = | 101 | struct cmd_results *error = |
102 | cmd_results_new(CMD_INVALID, message); | 102 | cmd_results_new(CMD_INVALID, "%s", message); |
103 | free(message); | 103 | free(message); |
104 | return error; | 104 | return error; |
105 | } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN | 105 | } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN |
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index b457f121..d44eb006 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -46,7 +46,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) { | |||
46 | } | 46 | } |
47 | 47 | ||
48 | if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) { | 48 | if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) { |
49 | return cmd_results_new(CMD_INVALID, expected_syntax); | 49 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
50 | } | 50 | } |
51 | 51 | ||
52 | struct sway_container *current = config->handler_context.container; | 52 | struct sway_container *current = config->handler_context.container; |
@@ -65,7 +65,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) { | |||
65 | other = root_find_container(test_mark, value); | 65 | other = root_find_container(test_mark, value); |
66 | } else { | 66 | } else { |
67 | free(value); | 67 | free(value); |
68 | return cmd_results_new(CMD_INVALID, expected_syntax); | 68 | return cmd_results_new(CMD_INVALID, "%s", expected_syntax); |
69 | } | 69 | } |
70 | 70 | ||
71 | if (!other) { | 71 | if (!other) { |
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index a6a0beda..03e488ba 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -61,7 +61,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv, | |||
61 | const char expected[] = "Expected 'workspace <name> gaps " | 61 | const char expected[] = "Expected 'workspace <name> gaps " |
62 | "inner|outer|horizontal|vertical|top|right|bottom|left <px>'"; | 62 | "inner|outer|horizontal|vertical|top|right|bottom|left <px>'"; |
63 | if (gaps_location == 0) { | 63 | if (gaps_location == 0) { |
64 | return cmd_results_new(CMD_INVALID, expected); | 64 | return cmd_results_new(CMD_INVALID, "%s", expected); |
65 | } | 65 | } |
66 | struct cmd_results *error = NULL; | 66 | struct cmd_results *error = NULL; |
67 | if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, | 67 | if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, |
@@ -79,7 +79,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv, | |||
79 | char *end; | 79 | char *end; |
80 | int amount = strtol(argv[gaps_location + 2], &end, 10); | 80 | int amount = strtol(argv[gaps_location + 2], &end, 10); |
81 | if (strlen(end)) { | 81 | if (strlen(end)) { |
82 | return cmd_results_new(CMD_FAILURE, expected); | 82 | return cmd_results_new(CMD_FAILURE, "%s", expected); |
83 | } | 83 | } |
84 | 84 | ||
85 | bool valid = false; | 85 | bool valid = false; |
@@ -110,7 +110,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv, | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | if (!valid) { | 112 | if (!valid) { |
113 | return cmd_results_new(CMD_INVALID, expected); | 113 | return cmd_results_new(CMD_INVALID, "%s", expected); |
114 | } | 114 | } |
115 | 115 | ||
116 | // Prevent invalid gaps configurations. | 116 | // Prevent invalid gaps configurations. |
@@ -174,7 +174,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
174 | } | 174 | } |
175 | 175 | ||
176 | if (root->fullscreen_global) { | 176 | if (root->fullscreen_global) { |
177 | return cmd_results_new(CMD_FAILURE, "workspace", | 177 | return cmd_results_new(CMD_FAILURE, |
178 | "Can't switch workspaces while fullscreen global"); | 178 | "Can't switch workspaces while fullscreen global"); |
179 | } | 179 | } |
180 | 180 | ||