aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/input
diff options
context:
space:
mode:
authorLibravatar Robert Kubosz <kubosz.robert@gmail.com>2018-07-11 22:03:06 +0200
committerLibravatar Robert Kubosz <kubosz.robert@gmail.com>2018-07-11 22:03:06 +0200
commit41b80c28dfafb9bc13b68e4d5d2811d311b59863 (patch)
treebbc7fe4664da4e25e9d66b87a216e64024856b31 /sway/commands/input
parentMerge pull request #2245 from RyanDwyer/floating-minmax-size (diff)
downloadsway-41b80c28dfafb9bc13b68e4d5d2811d311b59863.tar.gz
sway-41b80c28dfafb9bc13b68e4d5d2811d311b59863.tar.zst
sway-41b80c28dfafb9bc13b68e4d5d2811d311b59863.zip
add scroll button option
This commit introduces a scroll_button option, which is intended to be used with scroll_method. Now user can edit his sway config and add an scroll_button option to device section.
Diffstat (limited to 'sway/commands/input')
-rw-r--r--sway/commands/input/scroll_button.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sway/commands/input/scroll_button.c b/sway/commands/input/scroll_button.c
new file mode 100644
index 00000000..a9d697cf
--- /dev/null
+++ b/sway/commands/input/scroll_button.c
@@ -0,0 +1,31 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/config.h"
4#include "sway/commands.h"
5#include "sway/input/input-manager.h"
6
7struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "scroll_button", EXPECTED_AT_LEAST, 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, "scroll_button",
16 "No input device defined.");
17 }
18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
20
21 int scroll_button = atoi(argv[0]);
22 if (scroll_button < 1 || scroll_button > 10) {
23 free_input_config(new_config);
24 return cmd_results_new(CMD_INVALID, "scroll_button",
25 "Input out of range [1, 10]");
26 }
27 new_config->scroll_button = scroll_button;
28
29 apply_input_config(new_config);
30 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
31}