diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-14 01:01:47 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-14 01:01:47 -0400 |
commit | 13c6627ddb7dbe235426e123ee6ff8e6794bda6d (patch) | |
tree | 078891937a369fae4a7399374c58c3352734f199 | |
parent | Merge pull request #2244 from RyanDwyer/floating-resize (diff) | |
download | sway-13c6627ddb7dbe235426e123ee6ff8e6794bda6d.tar.gz sway-13c6627ddb7dbe235426e123ee6ff8e6794bda6d.tar.zst sway-13c6627ddb7dbe235426e123ee6ff8e6794bda6d.zip |
Implement tap_button_map for input devices
-rw-r--r-- | include/sway/commands.h | 1 | ||||
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | sway/commands/input.c | 1 | ||||
-rw-r--r-- | sway/commands/input/tap_button_map.c | 33 | ||||
-rw-r--r-- | sway/config/input.c | 4 | ||||
-rw-r--r-- | sway/input/input-manager.c | 6 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/sway-input.5.scd | 6 |
8 files changed, 53 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 32d6cefd..3ebd0002 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -210,6 +210,7 @@ sway_cmd input_cmd_repeat_rate; | |||
210 | sway_cmd input_cmd_scroll_button; | 210 | sway_cmd input_cmd_scroll_button; |
211 | sway_cmd input_cmd_scroll_method; | 211 | sway_cmd input_cmd_scroll_method; |
212 | sway_cmd input_cmd_tap; | 212 | sway_cmd input_cmd_tap; |
213 | sway_cmd input_cmd_tap_button_map; | ||
213 | sway_cmd input_cmd_xkb_layout; | 214 | sway_cmd input_cmd_xkb_layout; |
214 | sway_cmd input_cmd_xkb_model; | 215 | sway_cmd input_cmd_xkb_model; |
215 | sway_cmd input_cmd_xkb_options; | 216 | sway_cmd input_cmd_xkb_options; |
diff --git a/include/sway/config.h b/include/sway/config.h index 75acd4f2..f660a269 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -79,6 +79,7 @@ struct input_config { | |||
79 | int scroll_method; | 79 | int scroll_method; |
80 | int send_events; | 80 | int send_events; |
81 | int tap; | 81 | int tap; |
82 | int tap_button_map; | ||
82 | 83 | ||
83 | char *xkb_layout; | 84 | char *xkb_layout; |
84 | char *xkb_model; | 85 | char *xkb_model; |
diff --git a/sway/commands/input.c b/sway/commands/input.c index e7906b0e..5b203ea0 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c | |||
@@ -23,6 +23,7 @@ static struct cmd_handler input_handlers[] = { | |||
23 | { "scroll_button", input_cmd_scroll_button }, | 23 | { "scroll_button", input_cmd_scroll_button }, |
24 | { "scroll_method", input_cmd_scroll_method }, | 24 | { "scroll_method", input_cmd_scroll_method }, |
25 | { "tap", input_cmd_tap }, | 25 | { "tap", input_cmd_tap }, |
26 | { "tap_button_map", input_cmd_tap_button_map }, | ||
26 | { "xkb_layout", input_cmd_xkb_layout }, | 27 | { "xkb_layout", input_cmd_xkb_layout }, |
27 | { "xkb_model", input_cmd_xkb_model }, | 28 | { "xkb_model", input_cmd_xkb_model }, |
28 | { "xkb_options", input_cmd_xkb_options }, | 29 | { "xkb_options", input_cmd_xkb_options }, |
diff --git a/sway/commands/input/tap_button_map.c b/sway/commands/input/tap_button_map.c new file mode 100644 index 00000000..bdbba472 --- /dev/null +++ b/sway/commands/input/tap_button_map.c | |||
@@ -0,0 +1,33 @@ | |||
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 | |||
7 | struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "tap_button_map", 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, "tap_button_map", | ||
16 | "No input device defined."); | ||
17 | } | ||
18 | struct input_config *new_config = | ||
19 | new_input_config(current_input_config->identifier); | ||
20 | |||
21 | if (strcasecmp(argv[0], "lrm") == 0) { | ||
22 | new_config->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LRM; | ||
23 | } else if (strcasecmp(argv[0], "lmr") == 0) { | ||
24 | new_config->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR; | ||
25 | } else { | ||
26 | free_input_config(new_config); | ||
27 | return cmd_results_new(CMD_INVALID, "tap_button_map", | ||
28 | "Expected 'tap_button_map <lrm|lmr>'"); | ||
29 | } | ||
30 | |||
31 | apply_input_config(new_config); | ||
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
33 | } | ||
diff --git a/sway/config/input.c b/sway/config/input.c index cbd7d5f0..8d687a6d 100644 --- a/sway/config/input.c +++ b/sway/config/input.c | |||
@@ -19,6 +19,7 @@ struct input_config *new_input_config(const char* identifier) { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | input->tap = INT_MIN; | 21 | input->tap = INT_MIN; |
22 | input->tap_button_map = INT_MIN; | ||
22 | input->drag_lock = INT_MIN; | 23 | input->drag_lock = INT_MIN; |
23 | input->dwt = INT_MIN; | 24 | input->dwt = INT_MIN; |
24 | input->send_events = INT_MIN; | 25 | input->send_events = INT_MIN; |
@@ -80,6 +81,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) { | |||
80 | if (src->tap != INT_MIN) { | 81 | if (src->tap != INT_MIN) { |
81 | dst->tap = src->tap; | 82 | dst->tap = src->tap; |
82 | } | 83 | } |
84 | if (src->tap_button_map != INT_MIN) { | ||
85 | dst->tap_button_map = src->tap_button_map; | ||
86 | } | ||
83 | if (src->xkb_layout) { | 87 | if (src->xkb_layout) { |
84 | free(dst->xkb_layout); | 88 | free(dst->xkb_layout); |
85 | dst->xkb_layout = strdup(src->xkb_layout); | 89 | dst->xkb_layout = strdup(src->xkb_layout); |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index b18989d0..0b7cb766 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -181,6 +181,12 @@ static void input_manager_libinput_config_pointer( | |||
181 | ic->identifier, ic->tap); | 181 | ic->identifier, ic->tap); |
182 | libinput_device_config_tap_set_enabled(libinput_device, ic->tap); | 182 | libinput_device_config_tap_set_enabled(libinput_device, ic->tap); |
183 | } | 183 | } |
184 | if (ic->tap_button_map != INT_MIN) { | ||
185 | wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_button_map(%d)", | ||
186 | ic->identifier, ic->tap); | ||
187 | libinput_device_config_tap_set_button_map(libinput_device, | ||
188 | ic->tap_button_map); | ||
189 | } | ||
184 | } | 190 | } |
185 | 191 | ||
186 | static void handle_device_destroy(struct wl_listener *listener, void *data) { | 192 | static void handle_device_destroy(struct wl_listener *listener, void *data) { |
diff --git a/sway/meson.build b/sway/meson.build index 6fc78db3..f878450d 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -121,6 +121,7 @@ sway_sources = files( | |||
121 | 'commands/input/scroll_button.c', | 121 | 'commands/input/scroll_button.c', |
122 | 'commands/input/scroll_method.c', | 122 | 'commands/input/scroll_method.c', |
123 | 'commands/input/tap.c', | 123 | 'commands/input/tap.c', |
124 | 'commands/input/tap_button_map.c', | ||
124 | 'commands/input/xkb_layout.c', | 125 | 'commands/input/xkb_layout.c', |
125 | 'commands/input/xkb_model.c', | 126 | 'commands/input/xkb_model.c', |
126 | 'commands/input/xkb_options.c', | 127 | 'commands/input/xkb_options.c', |
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index 4bc66394..b6391431 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd | |||
@@ -100,6 +100,12 @@ For more information on these xkb configuration options, see | |||
100 | *input* <identifier> tap enabled|disabled | 100 | *input* <identifier> tap enabled|disabled |
101 | Enables or disables tap for specified input device. | 101 | Enables or disables tap for specified input device. |
102 | 102 | ||
103 | *input* <identifier> tap_button_map lrm|lmr | ||
104 | Specifies which button mapping to use for tapping. _lrm_ treats 1 finger as | ||
105 | left click, 2 fingers as right click, and 3 fingers as middle click. _lmr_ | ||
106 | treats 1 finger as left click, 2 fingers as middle click, and 3 fingers as | ||
107 | right click. | ||
108 | |||
103 | ## SEAT CONFIGURATION | 109 | ## SEAT CONFIGURATION |
104 | 110 | ||
105 | Configure options for multiseat mode. sway-seat commands must be used inside a | 111 | Configure options for multiseat mode. sway-seat commands must be used inside a |