diff options
author | Spencer Michaels <spencer@smichaels.net> | 2018-11-17 14:31:33 -0500 |
---|---|---|
committer | Spencer Michaels <spencer@smichaels.net> | 2018-11-18 13:49:30 -0500 |
commit | 70bc4c3ab6c408850543d827f788ef310fdb269c (patch) | |
tree | 265d4ea923f1329d1e7661c0f92a242337318d58 /sway/commands/input | |
parent | Merge pull request #3147 from emersion/set10 (diff) | |
download | sway-70bc4c3ab6c408850543d827f788ef310fdb269c.tar.gz sway-70bc4c3ab6c408850543d827f788ef310fdb269c.tar.zst sway-70bc4c3ab6c408850543d827f788ef310fdb269c.zip |
Add scroll factor config option.
Diffstat (limited to 'sway/commands/input')
-rw-r--r-- | sway/commands/input/pointer_accel.c | 9 | ||||
-rw-r--r-- | sway/commands/input/scroll_factor.c | 32 |
2 files changed, 39 insertions, 2 deletions
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c index df487b1c..efd81ee6 100644 --- a/sway/commands/input/pointer_accel.c +++ b/sway/commands/input/pointer_accel.c | |||
@@ -1,8 +1,10 @@ | |||
1 | #include <math.h> | ||
1 | #include <stdlib.h> | 2 | #include <stdlib.h> |
2 | #include <string.h> | 3 | #include <string.h> |
3 | #include "sway/config.h" | 4 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 5 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 6 | #include "sway/input/input-manager.h" |
7 | #include "util.h" | ||
6 | 8 | ||
7 | struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) { | 9 | struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 10 | struct cmd_results *error = NULL; |
@@ -15,8 +17,11 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) { | |||
15 | "pointer_accel", "No input device defined."); | 17 | "pointer_accel", "No input device defined."); |
16 | } | 18 | } |
17 | 19 | ||
18 | float pointer_accel = atof(argv[0]); | 20 | float pointer_accel = parse_float(argv[0]); |
19 | if (pointer_accel < -1 || pointer_accel > 1) { | 21 | if (isnan(pointer_accel)) { |
22 | return cmd_results_new(CMD_INVALID, "pointer_accel", | ||
23 | "Invalid pointer accel; expected float."); | ||
24 | } if (pointer_accel < -1 || pointer_accel > 1) { | ||
20 | return cmd_results_new(CMD_INVALID, "pointer_accel", | 25 | return cmd_results_new(CMD_INVALID, "pointer_accel", |
21 | "Input out of range [-1, 1]"); | 26 | "Input out of range [-1, 1]"); |
22 | } | 27 | } |
diff --git a/sway/commands/input/scroll_factor.c b/sway/commands/input/scroll_factor.c new file mode 100644 index 00000000..52d943b0 --- /dev/null +++ b/sway/commands/input/scroll_factor.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #include <errno.h> | ||
2 | #include <math.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <string.h> | ||
5 | #include "sway/config.h" | ||
6 | #include "sway/commands.h" | ||
7 | #include "sway/input/input-manager.h" | ||
8 | #include "util.h" | ||
9 | |||
10 | struct cmd_results *input_cmd_scroll_factor(int argc, char **argv) { | ||
11 | struct cmd_results *error = NULL; | ||
12 | if ((error = checkarg(argc, "scroll_factor", EXPECTED_AT_LEAST, 1))) { | ||
13 | return error; | ||
14 | } | ||
15 | struct input_config *ic = config->handler_context.input_config; | ||
16 | if (!ic) { | ||
17 | return cmd_results_new(CMD_FAILURE, | ||
18 | "scroll_factor", "No input device defined."); | ||
19 | } | ||
20 | |||
21 | float scroll_factor = parse_float(argv[0]); | ||
22 | if (isnan(scroll_factor)) { | ||
23 | return cmd_results_new(CMD_INVALID, "scroll_factor", | ||
24 | "Invalid scroll factor; expected float."); | ||
25 | } else if (scroll_factor < 0) { | ||
26 | return cmd_results_new(CMD_INVALID, "scroll_factor", | ||
27 | "Scroll factor cannot be negative."); | ||
28 | } | ||
29 | ic->scroll_factor = scroll_factor; | ||
30 | |||
31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
32 | } | ||