diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-04-19 13:47:29 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-04-19 13:47:29 +1000 |
commit | 9d3739a6f787edee185baa5e0746e72c07f9314f (patch) | |
tree | b9f0c61b3cde9ba7b54967acd8244420649eae19 /sway/commands/input/repeat_rate.c | |
parent | Make key repeat configurable (diff) | |
download | sway-9d3739a6f787edee185baa5e0746e72c07f9314f.tar.gz sway-9d3739a6f787edee185baa5e0746e72c07f9314f.tar.zst sway-9d3739a6f787edee185baa5e0746e72c07f9314f.zip |
Split repeat commands into separate files.
Diffstat (limited to 'sway/commands/input/repeat_rate.c')
-rw-r--r-- | sway/commands/input/repeat_rate.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/commands/input/repeat_rate.c b/sway/commands/input/repeat_rate.c new file mode 100644 index 00000000..f2ea2e69 --- /dev/null +++ b/sway/commands/input/repeat_rate.c | |||
@@ -0,0 +1,30 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <string.h> | ||
3 | #include "sway/config.h" | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/input/input-manager.h" | ||
6 | |||
7 | struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "repeat_rate", EXPECTED_EQUAL_TO, 1))) { | ||
10 | return error; | ||
11 | } | ||
12 | struct input_config *current_input_config = | ||
13 | config->handler_context.input_config; | ||
14 | if (!current_input_config) { | ||
15 | return cmd_results_new(CMD_FAILURE, | ||
16 | "repeat_rate", "No input device defined."); | ||
17 | } | ||
18 | struct input_config *new_config = | ||
19 | new_input_config(current_input_config->identifier); | ||
20 | |||
21 | int repeat_rate = atoi(argv[0]); | ||
22 | if (repeat_rate < 0) { | ||
23 | return cmd_results_new(CMD_INVALID, "repeat_rate", | ||
24 | "Repeat rate cannot be negative"); | ||
25 | } | ||
26 | new_config->repeat_rate = repeat_rate; | ||
27 | |||
28 | apply_input_config(new_config); | ||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
30 | } | ||