aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2019-01-13 20:40:00 -0500
committerLibravatar GitHub <noreply@github.com>2019-01-13 20:40:00 -0500
commitdb1631b67dd463f6516275ac4387712e39f9a384 (patch)
tree4dfb666777353f2d6bc77ec24d1a1b2b808925e0 /sway
parentMerge pull request #3402 from RyanDwyer/refactor-seatops (diff)
parentinput_cmd_scroll_button: utilize mouse btn helpers (diff)
downloadsway-db1631b67dd463f6516275ac4387712e39f9a384.tar.gz
sway-db1631b67dd463f6516275ac4387712e39f9a384.tar.zst
sway-db1631b67dd463f6516275ac4387712e39f9a384.zip
Merge pull request #3342 from RedSoxFan/scroll-buttons-improved
Improve mouse button parsing: input scroll_button
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/input/scroll_button.c34
-rw-r--r--sway/input/cursor.c2
-rw-r--r--sway/sway-input.5.scd9
3 files changed, 24 insertions, 21 deletions
diff --git a/sway/commands/input/scroll_button.c b/sway/commands/input/scroll_button.c
index 1958f23c..d82a1fe1 100644
--- a/sway/commands/input/scroll_button.c
+++ b/sway/commands/input/scroll_button.c
@@ -1,9 +1,7 @@
1#include <string.h> 1#include <libevdev/libevdev.h>
2#include <strings.h>
3#include <errno.h>
4#include "sway/config.h" 2#include "sway/config.h"
5#include "sway/commands.h" 3#include "sway/commands.h"
6#include "sway/input/input-manager.h" 4#include "sway/input/cursor.h"
7 5
8struct cmd_results *input_cmd_scroll_button(int argc, char **argv) { 6struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
9 struct cmd_results *error = NULL; 7 struct cmd_results *error = NULL;
@@ -16,22 +14,26 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
16 "No input device defined."); 14 "No input device defined.");
17 } 15 }
18 16
19 errno = 0; 17 if (strcmp(*argv, "disable") == 0) {
20 char *endptr; 18 ic->scroll_button = 0;
21 int scroll_button = strtol(*argv, &endptr, 10); 19 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
22 if (endptr == *argv && scroll_button == 0) {
23 return cmd_results_new(CMD_INVALID, "scroll_button",
24 "Scroll button identifier must be an integer.");
25 } 20 }
26 if (errno == ERANGE) { 21
22 char *message = NULL;
23 uint32_t button = get_mouse_button(*argv, &message);
24 if (message) {
25 error = cmd_results_new(CMD_INVALID, "scroll_button", message);
26 free(message);
27 return error;
28 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
29 || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) {
27 return cmd_results_new(CMD_INVALID, "scroll_button", 30 return cmd_results_new(CMD_INVALID, "scroll_button",
28 "Scroll button identifier out of range."); 31 "X11 axis buttons are not supported for scroll_button");
29 } 32 } else if (!button) {
30 if (scroll_button < 0) {
31 return cmd_results_new(CMD_INVALID, "scroll_button", 33 return cmd_results_new(CMD_INVALID, "scroll_button",
32 "Scroll button identifier cannot be negative."); 34 "Unknown button %s", *argv);
33 } 35 }
34 ic->scroll_button = scroll_button; 36 ic->scroll_button = button;
35 37
36 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 38 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
37} 39}
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 06294b8b..c65548c3 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -1227,7 +1227,7 @@ uint32_t get_mouse_bindcode(const char *name, char **error) {
1227 1227
1228uint32_t get_mouse_button(const char *name, char **error) { 1228uint32_t get_mouse_button(const char *name, char **error) {
1229 uint32_t button = get_mouse_bindsym(name, error); 1229 uint32_t button = get_mouse_bindsym(name, error);
1230 if (!button && !error) { 1230 if (!button && !*error) {
1231 button = get_mouse_bindcode(name, error); 1231 button = get_mouse_bindcode(name, error);
1232 } 1232 }
1233 return button; 1233 return button;
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index c54babaa..7d1a7169 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -108,10 +108,11 @@ The following commands may only be used in the configuration file.
108*input* <identifier> repeat\_rate <characters per second> 108*input* <identifier> repeat\_rate <characters per second>
109 Sets the frequency of key repeats once the repeat\_delay has passed. 109 Sets the frequency of key repeats once the repeat\_delay has passed.
110 110
111*input* <identifier> scroll\_button <button\_identifier> 111*input* <identifier> scroll\_button disable|button[1-3,8,9]|<event-code-or-name>
112 Sets button used for scroll\_method on\_button\_down. The button identifier 112 Sets the button used for scroll\_method on\_button\_down. The button can
113 can be obtained from `libinput debug-events`. 113 be given as an event name or code, which can be obtained from `libinput
114 If set to 0, it disables the scroll\_button on\_button\_down. 114 debug-events`, or as a x11 mouse button (button[1-3,8,9]). If set to
115 _disable_, it disables the scroll\_method on\_button\_down.
115 116
116*input* <identifier> scroll\_factor <floating point value> 117*input* <identifier> scroll\_factor <floating point value>
117 Changes the scroll factor for the specified input device. Scroll speed will 118 Changes the scroll factor for the specified input device. Scroll speed will