diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-23 15:04:46 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-23 21:33:17 -0400 |
commit | 863914ec9574eb58cb0746d59f216997c4863cdf (patch) | |
tree | aaddd8ae854d1dde4b50cfd4ef470c1acf83b6ce /sway/commands/input | |
parent | Merge pull request #2342 from RyanDwyer/update-cursor (diff) | |
download | sway-863914ec9574eb58cb0746d59f216997c4863cdf.tar.gz sway-863914ec9574eb58cb0746d59f216997c4863cdf.tar.zst sway-863914ec9574eb58cb0746d59f216997c4863cdf.zip |
Switch to using a function to parse booleans
Diffstat (limited to 'sway/commands/input')
-rw-r--r-- | sway/commands/input/drag_lock.c | 9 | ||||
-rw-r--r-- | sway/commands/input/dwt.c | 9 | ||||
-rw-r--r-- | sway/commands/input/left_handed.c | 11 | ||||
-rw-r--r-- | sway/commands/input/middle_emulation.c | 9 | ||||
-rw-r--r-- | sway/commands/input/natural_scroll.c | 11 | ||||
-rw-r--r-- | sway/commands/input/tap.c | 9 |
6 files changed, 16 insertions, 42 deletions
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c index 9e32816f..f9ddeef2 100644 --- a/sway/commands/input/drag_lock.c +++ b/sway/commands/input/drag_lock.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,14 +19,10 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | if (parse_boolean(argv[0], true)) { |
22 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; | 23 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; |
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; | ||
25 | } else { | 24 | } else { |
26 | free_input_config(new_config); | 25 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; |
27 | return cmd_results_new(CMD_INVALID, "drag_lock", | ||
28 | "Expected 'drag_lock <enabled|disabled>'"); | ||
29 | } | 26 | } |
30 | 27 | ||
31 | apply_input_config(new_config); | 28 | apply_input_config(new_config); |
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c index 73937507..15134268 100644 --- a/sway/commands/input/dwt.c +++ b/sway/commands/input/dwt.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_dwt(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_dwt(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -17,14 +18,10 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) { | |||
17 | struct input_config *new_config = | 18 | struct input_config *new_config = |
18 | new_input_config(current_input_config->identifier); | 19 | new_input_config(current_input_config->identifier); |
19 | 20 | ||
20 | if (strcasecmp(argv[0], "enabled") == 0) { | 21 | if (parse_boolean(argv[0], true)) { |
21 | new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; | 22 | new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; |
22 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
23 | new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; | ||
24 | } else { | 23 | } else { |
25 | free_input_config(new_config); | 24 | new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; |
26 | return cmd_results_new(CMD_INVALID, "dwt", | ||
27 | "Expected 'dwt <enabled|disabled>'"); | ||
28 | } | 25 | } |
29 | 26 | ||
30 | apply_input_config(new_config); | 27 | apply_input_config(new_config); |
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c index 769ce98c..e770043a 100644 --- a/sway/commands/input/left_handed.c +++ b/sway/commands/input/left_handed.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_left_handed(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_left_handed(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,15 +19,7 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | new_config->left_handed = parse_boolean(argv[0], true); |
22 | new_config->left_handed = 1; | ||
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->left_handed = 0; | ||
25 | } else { | ||
26 | free_input_config(new_config); | ||
27 | return cmd_results_new(CMD_INVALID, "left_handed", | ||
28 | "Expected 'left_handed <enabled|disabled>'"); | ||
29 | } | ||
30 | 23 | ||
31 | apply_input_config(new_config); | 24 | apply_input_config(new_config); |
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c index 7ca01629..414d4d2b 100644 --- a/sway/commands/input/middle_emulation.c +++ b/sway/commands/input/middle_emulation.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,15 +19,11 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | if (parse_boolean(argv[0], true)) { |
22 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; | 23 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; |
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 24 | } else { |
24 | new_config->middle_emulation = | 25 | new_config->middle_emulation = |
25 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; | 26 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; |
26 | } else { | ||
27 | free_input_config(new_config); | ||
28 | return cmd_results_new(CMD_INVALID, "middle_emulation", | ||
29 | "Expected 'middle_emulation <enabled|disabled>'"); | ||
30 | } | 27 | } |
31 | 28 | ||
32 | apply_input_config(new_config); | 29 | apply_input_config(new_config); |
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c index 55236790..77c3ff00 100644 --- a/sway/commands/input/natural_scroll.c +++ b/sway/commands/input/natural_scroll.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,15 +19,7 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | new_config->natural_scroll = parse_boolean(argv[0], true); |
22 | new_config->natural_scroll = 1; | ||
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->natural_scroll = 0; | ||
25 | } else { | ||
26 | free_input_config(new_config); | ||
27 | return cmd_results_new(CMD_INVALID, "natural_scroll", | ||
28 | "Expected 'natural_scroll <enabled|disabled>'"); | ||
29 | } | ||
30 | 23 | ||
31 | apply_input_config(new_config); | 24 | apply_input_config(new_config); |
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c index a8d1a10c..ac3b8237 100644 --- a/sway/commands/input/tap.c +++ b/sway/commands/input/tap.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "log.h" | 6 | #include "log.h" |
7 | #include "util.h" | ||
7 | 8 | ||
8 | struct cmd_results *input_cmd_tap(int argc, char **argv) { | 9 | struct cmd_results *input_cmd_tap(int argc, char **argv) { |
9 | struct cmd_results *error = NULL; | 10 | struct cmd_results *error = NULL; |
@@ -18,14 +19,10 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | if (parse_boolean(argv[0], true)) { |
22 | new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; | 23 | new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; |
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; | ||
25 | } else { | 24 | } else { |
26 | free_input_config(new_config); | 25 | new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; |
27 | return cmd_results_new(CMD_INVALID, "tap", | ||
28 | "Expected 'tap <enabled|disabled>'"); | ||
29 | } | 26 | } |
30 | 27 | ||
31 | wlr_log(WLR_DEBUG, "apply-tap for device: %s", | 28 | wlr_log(WLR_DEBUG, "apply-tap for device: %s", |