summaryrefslogtreecommitdiffstats
path: root/sway/commands/input
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/input')
-rw-r--r--sway/commands/input/accel_profile.c7
-rw-r--r--sway/commands/input/click_method.c7
-rw-r--r--sway/commands/input/drag.c5
-rw-r--r--sway/commands/input/drag_lock.c5
-rw-r--r--sway/commands/input/dwt.c4
-rw-r--r--sway/commands/input/events.c9
-rw-r--r--sway/commands/input/left_handed.c5
-rw-r--r--sway/commands/input/map_from_region.c16
-rw-r--r--sway/commands/input/map_to_output.c5
-rw-r--r--sway/commands/input/middle_emulation.c5
-rw-r--r--sway/commands/input/natural_scroll.c5
-rw-r--r--sway/commands/input/pointer_accel.c10
-rw-r--r--sway/commands/input/repeat_delay.c8
-rw-r--r--sway/commands/input/repeat_rate.c8
-rw-r--r--sway/commands/input/scroll_button.c14
-rw-r--r--sway/commands/input/scroll_factor.c9
-rw-r--r--sway/commands/input/scroll_method.c7
-rw-r--r--sway/commands/input/tap.c4
-rw-r--r--sway/commands/input/tap_button_map.c7
-rw-r--r--sway/commands/input/xkb_capslock.c5
-rw-r--r--sway/commands/input/xkb_layout.c5
-rw-r--r--sway/commands/input/xkb_model.c5
-rw-r--r--sway/commands/input/xkb_numlock.c5
-rw-r--r--sway/commands/input/xkb_options.c5
-rw-r--r--sway/commands/input/xkb_rules.c5
-rw-r--r--sway/commands/input/xkb_variant.c5
26 files changed, 72 insertions, 103 deletions
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
index f7016790..08f324cc 100644
--- a/sway/commands/input/accel_profile.c
+++ b/sway/commands/input/accel_profile.c
@@ -11,8 +11,7 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "accel_profile", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 if (strcasecmp(argv[0], "adaptive") == 0) { 17 if (strcasecmp(argv[0], "adaptive") == 0) {
@@ -20,9 +19,9 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
20 } else if (strcasecmp(argv[0], "flat") == 0) { 19 } else if (strcasecmp(argv[0], "flat") == 0) {
21 ic->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; 20 ic->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
22 } else { 21 } else {
23 return cmd_results_new(CMD_INVALID, "accel_profile", 22 return cmd_results_new(CMD_INVALID,
24 "Expected 'accel_profile <adaptive|flat>'"); 23 "Expected 'accel_profile <adaptive|flat>'");
25 } 24 }
26 25
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL);
28} 27}
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
index 24777475..03fcb458 100644
--- a/sway/commands/input/click_method.c
+++ b/sway/commands/input/click_method.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "click_method", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 if (strcasecmp(argv[0], "none") == 0) { 18 if (strcasecmp(argv[0], "none") == 0) {
@@ -23,9 +22,9 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
23 } else if (strcasecmp(argv[0], "clickfinger") == 0) { 22 } else if (strcasecmp(argv[0], "clickfinger") == 0) {
24 ic->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; 23 ic->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
25 } else { 24 } else {
26 return cmd_results_new(CMD_INVALID, "click_method", 25 return cmd_results_new(CMD_INVALID,
27 "Expected 'click_method <none|button_areas|clickfinger'>"); 26 "Expected 'click_method <none|button_areas|clickfinger'>");
28 } 27 }
29 28
30 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 29 return cmd_results_new(CMD_SUCCESS, NULL);
31} 30}
diff --git a/sway/commands/input/drag.c b/sway/commands/input/drag.c
index e325df29..062357d4 100644
--- a/sway/commands/input/drag.c
+++ b/sway/commands/input/drag.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_drag(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "drag", "No input device defined.");
17 } 16 }
18 17
19 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -22,5 +21,5 @@ struct cmd_results *input_cmd_drag(int argc, char **argv) {
22 ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED; 21 ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED;
23 } 22 }
24 23
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
index db5d5afa..24c548e2 100644
--- a/sway/commands/input/drag_lock.c
+++ b/sway/commands/input/drag_lock.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "drag_lock", "No input device defined.");
17 } 16 }
18 17
19 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -22,5 +21,5 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
22 ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; 21 ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
23 } 22 }
24 23
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
index 0c3881dd..a7a4e494 100644
--- a/sway/commands/input/dwt.c
+++ b/sway/commands/input/dwt.c
@@ -12,7 +12,7 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 } 16 }
17 17
18 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -21,5 +21,5 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
21 ic->dwt = LIBINPUT_CONFIG_DWT_DISABLED; 21 ic->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
22 } 22 }
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index 69f46269..2c6505d8 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -71,8 +71,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
71 } 71 }
72 struct input_config *ic = config->handler_context.input_config; 72 struct input_config *ic = config->handler_context.input_config;
73 if (!ic) { 73 if (!ic) {
74 return cmd_results_new(CMD_FAILURE, "events", 74 return cmd_results_new(CMD_FAILURE, "No input device defined.");
75 "No input device defined.");
76 } 75 }
77 76
78 if (strcasecmp(argv[0], "enabled") == 0) { 77 if (strcasecmp(argv[0], "enabled") == 0) {
@@ -83,7 +82,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
83 ic->send_events = 82 ic->send_events =
84 LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; 83 LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
85 } else if (config->reading) { 84 } else if (config->reading) {
86 return cmd_results_new(CMD_INVALID, "events", 85 return cmd_results_new(CMD_INVALID,
87 "Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); 86 "Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
88 } else if (strcasecmp(argv[0], "toggle") == 0) { 87 } else if (strcasecmp(argv[0], "toggle") == 0) {
89 if (strcmp(ic->identifier, "*") == 0) { 88 if (strcmp(ic->identifier, "*") == 0) {
@@ -97,10 +96,10 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
97 toggle_send_events(ic); 96 toggle_send_events(ic);
98 } 97 }
99 } else { 98 } else {
100 return cmd_results_new(CMD_INVALID, "events", 99 return cmd_results_new(CMD_INVALID,
101 "Expected 'events <enabled|disabled|disabled_on_external_mouse|" 100 "Expected 'events <enabled|disabled|disabled_on_external_mouse|"
102 "toggle>'"); 101 "toggle>'");
103 } 102 }
104 103
105 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 104 return cmd_results_new(CMD_SUCCESS, NULL);
106} 105}
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
index 2e0f757b..93d8d56d 100644
--- a/sway/commands/input/left_handed.c
+++ b/sway/commands/input/left_handed.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "left_handed", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->left_handed = parse_boolean(argv[0], true); 18 ic->left_handed = parse_boolean(argv[0], true);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c
index 53608a67..de00b714 100644
--- a/sway/commands/input/map_from_region.c
+++ b/sway/commands/input/map_from_region.c
@@ -40,8 +40,7 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
40 } 40 }
41 struct input_config *ic = config->handler_context.input_config; 41 struct input_config *ic = config->handler_context.input_config;
42 if (!ic) { 42 if (!ic) {
43 return cmd_results_new(CMD_FAILURE, "map_from_region", 43 return cmd_results_new(CMD_FAILURE, "No input device defined");
44 "No input device defined");
45 } 44 }
46 45
47 ic->mapped_from_region = 46 ic->mapped_from_region =
@@ -52,30 +51,27 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
52 &ic->mapped_from_region->y1, &mm1)) { 51 &ic->mapped_from_region->y1, &mm1)) {
53 free(ic->mapped_from_region); 52 free(ic->mapped_from_region);
54 ic->mapped_from_region = NULL; 53 ic->mapped_from_region = NULL;
55 return cmd_results_new(CMD_FAILURE, "map_from_region", 54 return cmd_results_new(CMD_FAILURE, "Invalid top-left coordinates");
56 "Invalid top-left coordinates");
57 } 55 }
58 if (!parse_coords(argv[1], &ic->mapped_from_region->x2, 56 if (!parse_coords(argv[1], &ic->mapped_from_region->x2,
59 &ic->mapped_from_region->y2, &mm2)) { 57 &ic->mapped_from_region->y2, &mm2)) {
60 free(ic->mapped_from_region); 58 free(ic->mapped_from_region);
61 ic->mapped_from_region = NULL; 59 ic->mapped_from_region = NULL;
62 return cmd_results_new(CMD_FAILURE, "map_from_region", 60 return cmd_results_new(CMD_FAILURE, "Invalid bottom-right coordinates");
63 "Invalid bottom-right coordinates");
64 } 61 }
65 if (ic->mapped_from_region->x1 > ic->mapped_from_region->x2 || 62 if (ic->mapped_from_region->x1 > ic->mapped_from_region->x2 ||
66 ic->mapped_from_region->y1 > ic->mapped_from_region->y2) { 63 ic->mapped_from_region->y1 > ic->mapped_from_region->y2) {
67 free(ic->mapped_from_region); 64 free(ic->mapped_from_region);
68 ic->mapped_from_region = NULL; 65 ic->mapped_from_region = NULL;
69 return cmd_results_new(CMD_FAILURE, "map_from_region", 66 return cmd_results_new(CMD_FAILURE, "Invalid rectangle");
70 "Invalid rectangle");
71 } 67 }
72 if (mm1 != mm2) { 68 if (mm1 != mm2) {
73 free(ic->mapped_from_region); 69 free(ic->mapped_from_region);
74 ic->mapped_from_region = NULL; 70 ic->mapped_from_region = NULL;
75 return cmd_results_new(CMD_FAILURE, "map_from_region", 71 return cmd_results_new(CMD_FAILURE,
76 "Both coordinates must be in the same unit"); 72 "Both coordinates must be in the same unit");
77 } 73 }
78 ic->mapped_from_region->mm = mm1; 74 ic->mapped_from_region->mm = mm1;
79 75
80 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 76 return cmd_results_new(CMD_SUCCESS, NULL);
81} 77}
diff --git a/sway/commands/input/map_to_output.c b/sway/commands/input/map_to_output.c
index 8b16c557..6d623186 100644
--- a/sway/commands/input/map_to_output.c
+++ b/sway/commands/input/map_to_output.c
@@ -13,11 +13,10 @@ struct cmd_results *input_cmd_map_to_output(int argc, char **argv) {
13 } 13 }
14 struct input_config *ic = config->handler_context.input_config; 14 struct input_config *ic = config->handler_context.input_config;
15 if (!ic) { 15 if (!ic) {
16 return cmd_results_new(CMD_FAILURE, "map_to_output", 16 return cmd_results_new(CMD_FAILURE, "No input device defined.");
17 "No input device defined.");
18 } 17 }
19 18
20 ic->mapped_to_output = strdup(argv[0]); 19 ic->mapped_to_output = strdup(argv[0]);
21 20
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
index 80d26838..9f32692e 100644
--- a/sway/commands/input/middle_emulation.c
+++ b/sway/commands/input/middle_emulation.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "middle_emulation", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -22,5 +21,5 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
22 ic->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; 21 ic->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
23 } 22 }
24 23
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
index e2a93500..dec32a5b 100644
--- a/sway/commands/input/natural_scroll.c
+++ b/sway/commands/input/natural_scroll.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "natural_scoll", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->natural_scroll = parse_boolean(argv[0], true); 18 ic->natural_scroll = parse_boolean(argv[0], true);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
index efd81ee6..e214b32f 100644
--- a/sway/commands/input/pointer_accel.c
+++ b/sway/commands/input/pointer_accel.c
@@ -13,19 +13,17 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
13 } 13 }
14 struct input_config *ic = config->handler_context.input_config; 14 struct input_config *ic = config->handler_context.input_config;
15 if (!ic) { 15 if (!ic) {
16 return cmd_results_new(CMD_FAILURE, 16 return cmd_results_new(CMD_FAILURE, "No input device defined.");
17 "pointer_accel", "No input device defined.");
18 } 17 }
19 18
20 float pointer_accel = parse_float(argv[0]); 19 float pointer_accel = parse_float(argv[0]);
21 if (isnan(pointer_accel)) { 20 if (isnan(pointer_accel)) {
22 return cmd_results_new(CMD_INVALID, "pointer_accel", 21 return cmd_results_new(CMD_INVALID,
23 "Invalid pointer accel; expected float."); 22 "Invalid pointer accel; expected float.");
24 } if (pointer_accel < -1 || pointer_accel > 1) { 23 } if (pointer_accel < -1 || pointer_accel > 1) {
25 return cmd_results_new(CMD_INVALID, "pointer_accel", 24 return cmd_results_new(CMD_INVALID, "Input out of range [-1, 1]");
26 "Input out of range [-1, 1]");
27 } 25 }
28 ic->pointer_accel = pointer_accel; 26 ic->pointer_accel = pointer_accel;
29 27
30 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL);
31} 29}
diff --git a/sway/commands/input/repeat_delay.c b/sway/commands/input/repeat_delay.c
index d94b3e4d..5b787fe6 100644
--- a/sway/commands/input/repeat_delay.c
+++ b/sway/commands/input/repeat_delay.c
@@ -11,16 +11,14 @@ struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "repeat_delay", "No input device defined.");
16 } 15 }
17 16
18 int repeat_delay = atoi(argv[0]); 17 int repeat_delay = atoi(argv[0]);
19 if (repeat_delay < 0) { 18 if (repeat_delay < 0) {
20 return cmd_results_new(CMD_INVALID, "repeat_delay", 19 return cmd_results_new(CMD_INVALID, "Repeat delay cannot be negative");
21 "Repeat delay cannot be negative");
22 } 20 }
23 ic->repeat_delay = repeat_delay; 21 ic->repeat_delay = repeat_delay;
24 22
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 23 return cmd_results_new(CMD_SUCCESS, NULL);
26} 24}
diff --git a/sway/commands/input/repeat_rate.c b/sway/commands/input/repeat_rate.c
index ebec4cdb..79c5efe2 100644
--- a/sway/commands/input/repeat_rate.c
+++ b/sway/commands/input/repeat_rate.c
@@ -11,16 +11,14 @@ struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "repeat_rate", "No input device defined.");
16 } 15 }
17 16
18 int repeat_rate = atoi(argv[0]); 17 int repeat_rate = atoi(argv[0]);
19 if (repeat_rate < 0) { 18 if (repeat_rate < 0) {
20 return cmd_results_new(CMD_INVALID, "repeat_rate", 19 return cmd_results_new(CMD_INVALID, "Repeat rate cannot be negative");
21 "Repeat rate cannot be negative");
22 } 20 }
23 ic->repeat_rate = repeat_rate; 21 ic->repeat_rate = repeat_rate;
24 22
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 23 return cmd_results_new(CMD_SUCCESS, NULL);
26} 24}
diff --git a/sway/commands/input/scroll_button.c b/sway/commands/input/scroll_button.c
index d82a1fe1..6b331419 100644
--- a/sway/commands/input/scroll_button.c
+++ b/sway/commands/input/scroll_button.c
@@ -10,30 +10,28 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
10 } 10 }
11 struct input_config *ic = config->handler_context.input_config; 11 struct input_config *ic = config->handler_context.input_config;
12 if (!ic) { 12 if (!ic) {
13 return cmd_results_new(CMD_FAILURE, "scroll_button", 13 return cmd_results_new(CMD_FAILURE, "No input device defined.");
14 "No input device defined.");
15 } 14 }
16 15
17 if (strcmp(*argv, "disable") == 0) { 16 if (strcmp(*argv, "disable") == 0) {
18 ic->scroll_button = 0; 17 ic->scroll_button = 0;
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 18 return cmd_results_new(CMD_SUCCESS, NULL);
20 } 19 }
21 20
22 char *message = NULL; 21 char *message = NULL;
23 uint32_t button = get_mouse_button(*argv, &message); 22 uint32_t button = get_mouse_button(*argv, &message);
24 if (message) { 23 if (message) {
25 error = cmd_results_new(CMD_INVALID, "scroll_button", message); 24 error = cmd_results_new(CMD_INVALID, message);
26 free(message); 25 free(message);
27 return error; 26 return error;
28 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN 27 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
29 || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) { 28 || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) {
30 return cmd_results_new(CMD_INVALID, "scroll_button", 29 return cmd_results_new(CMD_INVALID,
31 "X11 axis buttons are not supported for scroll_button"); 30 "X11 axis buttons are not supported for scroll_button");
32 } else if (!button) { 31 } else if (!button) {
33 return cmd_results_new(CMD_INVALID, "scroll_button", 32 return cmd_results_new(CMD_INVALID, "Unknown button %s", *argv);
34 "Unknown button %s", *argv);
35 } 33 }
36 ic->scroll_button = button; 34 ic->scroll_button = button;
37 35
38 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 36 return cmd_results_new(CMD_SUCCESS, NULL);
39} 37}
diff --git a/sway/commands/input/scroll_factor.c b/sway/commands/input/scroll_factor.c
index 52d943b0..4b72b6fa 100644
--- a/sway/commands/input/scroll_factor.c
+++ b/sway/commands/input/scroll_factor.c
@@ -14,19 +14,18 @@ struct cmd_results *input_cmd_scroll_factor(int argc, char **argv) {
14 } 14 }
15 struct input_config *ic = config->handler_context.input_config; 15 struct input_config *ic = config->handler_context.input_config;
16 if (!ic) { 16 if (!ic) {
17 return cmd_results_new(CMD_FAILURE, 17 return cmd_results_new(CMD_FAILURE, "No input device defined.");
18 "scroll_factor", "No input device defined.");
19 } 18 }
20 19
21 float scroll_factor = parse_float(argv[0]); 20 float scroll_factor = parse_float(argv[0]);
22 if (isnan(scroll_factor)) { 21 if (isnan(scroll_factor)) {
23 return cmd_results_new(CMD_INVALID, "scroll_factor", 22 return cmd_results_new(CMD_INVALID,
24 "Invalid scroll factor; expected float."); 23 "Invalid scroll factor; expected float.");
25 } else if (scroll_factor < 0) { 24 } else if (scroll_factor < 0) {
26 return cmd_results_new(CMD_INVALID, "scroll_factor", 25 return cmd_results_new(CMD_INVALID,
27 "Scroll factor cannot be negative."); 26 "Scroll factor cannot be negative.");
28 } 27 }
29 ic->scroll_factor = scroll_factor; 28 ic->scroll_factor = scroll_factor;
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
index c116b052..cd8b5f7a 100644
--- a/sway/commands/input/scroll_method.c
+++ b/sway/commands/input/scroll_method.c
@@ -11,8 +11,7 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "scroll_method", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 if (strcasecmp(argv[0], "none") == 0) { 17 if (strcasecmp(argv[0], "none") == 0) {
@@ -24,9 +23,9 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
24 } else if (strcasecmp(argv[0], "on_button_down") == 0) { 23 } else if (strcasecmp(argv[0], "on_button_down") == 0) {
25 ic->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; 24 ic->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
26 } else { 25 } else {
27 return cmd_results_new(CMD_INVALID, "scroll_method", 26 return cmd_results_new(CMD_INVALID,
28 "Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); 27 "Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
29 } 28 }
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
index c455b696..443fd49d 100644
--- a/sway/commands/input/tap.c
+++ b/sway/commands/input/tap.c
@@ -13,7 +13,7 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
13 } 13 }
14 struct input_config *ic = config->handler_context.input_config; 14 struct input_config *ic = config->handler_context.input_config;
15 if (!ic) { 15 if (!ic) {
16 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); 16 return cmd_results_new(CMD_FAILURE, "No input device defined.");
17 } 17 }
18 18
19 if (parse_boolean(argv[0], true)) { 19 if (parse_boolean(argv[0], true)) {
@@ -22,5 +22,5 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
22 ic->tap = LIBINPUT_CONFIG_TAP_DISABLED; 22 ic->tap = LIBINPUT_CONFIG_TAP_DISABLED;
23 } 23 }
24 24
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 25 return cmd_results_new(CMD_SUCCESS, NULL);
26} 26}
diff --git a/sway/commands/input/tap_button_map.c b/sway/commands/input/tap_button_map.c
index dff2985b..77ac6de7 100644
--- a/sway/commands/input/tap_button_map.c
+++ b/sway/commands/input/tap_button_map.c
@@ -11,8 +11,7 @@ struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "tap_button_map", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 if (strcasecmp(argv[0], "lrm") == 0) { 17 if (strcasecmp(argv[0], "lrm") == 0) {
@@ -20,9 +19,9 @@ struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
20 } else if (strcasecmp(argv[0], "lmr") == 0) { 19 } else if (strcasecmp(argv[0], "lmr") == 0) {
21 ic->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR; 20 ic->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
22 } else { 21 } else {
23 return cmd_results_new(CMD_INVALID, "tap_button_map", 22 return cmd_results_new(CMD_INVALID,
24 "Expected 'tap_button_map <lrm|lmr>'"); 23 "Expected 'tap_button_map <lrm|lmr>'");
25 } 24 }
26 25
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL);
28} 27}
diff --git a/sway/commands/input/xkb_capslock.c b/sway/commands/input/xkb_capslock.c
index a939c72f..7ce98ebb 100644
--- a/sway/commands/input/xkb_capslock.c
+++ b/sway/commands/input/xkb_capslock.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "xkb_capslock", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->xkb_capslock = parse_boolean(argv[0], false); 18 ic->xkb_capslock = parse_boolean(argv[0], false);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/xkb_layout.c b/sway/commands/input/xkb_layout.c
index 43166401..c9200aa2 100644
--- a/sway/commands/input/xkb_layout.c
+++ b/sway/commands/input/xkb_layout.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_layout", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_layout = strdup(argv[0]); 17 ic->xkb_layout = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_layout for config: %s layout: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_layout for config: %s layout: %s",
21 ic->identifier, ic->xkb_layout); 20 ic->identifier, ic->xkb_layout);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_model.c b/sway/commands/input/xkb_model.c
index 066f632b..763ae80e 100644
--- a/sway/commands/input/xkb_model.c
+++ b/sway/commands/input/xkb_model.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_model", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_model = strdup(argv[0]); 17 ic->xkb_model = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_model for config: %s model: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_model for config: %s model: %s",
21 ic->identifier, ic->xkb_model); 20 ic->identifier, ic->xkb_model);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_numlock.c b/sway/commands/input/xkb_numlock.c
index 2e962c5b..d5b75672 100644
--- a/sway/commands/input/xkb_numlock.c
+++ b/sway/commands/input/xkb_numlock.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "xkb_numlock", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->xkb_numlock = parse_boolean(argv[0], false); 18 ic->xkb_numlock = parse_boolean(argv[0], false);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/xkb_options.c b/sway/commands/input/xkb_options.c
index 09dc4a5c..1ff6e680 100644
--- a/sway/commands/input/xkb_options.c
+++ b/sway/commands/input/xkb_options.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_options", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_options = strdup(argv[0]); 17 ic->xkb_options = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_options for config: %s options: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_options for config: %s options: %s",
21 ic->identifier, ic->xkb_options); 20 ic->identifier, ic->xkb_options);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c
index d3e576e6..29172b24 100644
--- a/sway/commands/input/xkb_rules.c
+++ b/sway/commands/input/xkb_rules.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_rules", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_rules = strdup(argv[0]); 17 ic->xkb_rules = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_rules for config: %s rules: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_rules for config: %s rules: %s",
21 ic->identifier, ic->xkb_rules); 20 ic->identifier, ic->xkb_rules);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_variant.c b/sway/commands/input/xkb_variant.c
index 2d7581d1..9f3baed6 100644
--- a/sway/commands/input/xkb_variant.c
+++ b/sway/commands/input/xkb_variant.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_variant", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_variant = strdup(argv[0]); 17 ic->xkb_variant = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_variant for config: %s variant: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_variant for config: %s variant: %s",
21 ic->identifier, ic->xkb_variant); 20 ic->identifier, ic->xkb_variant);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}