diff options
author | PP <34623266+PumbaPe@users.noreply.github.com> | 2018-09-29 11:49:41 +0200 |
---|---|---|
committer | PP <34623266+PumbaPe@users.noreply.github.com> | 2018-09-29 11:49:41 +0200 |
commit | ae2b70f59ec988ae1ad108316ec04d1f634ec735 (patch) | |
tree | dcd6007eede8002b9b2306311a6ec4cc19b2bdd6 | |
parent | Merge pull request #2723 from ianyfan/swaybar (diff) | |
download | sway-ae2b70f59ec988ae1ad108316ec04d1f634ec735.tar.gz sway-ae2b70f59ec988ae1ad108316ec04d1f634ec735.tar.zst sway-ae2b70f59ec988ae1ad108316ec04d1f634ec735.zip |
add tap-and-drag setting to sway-input
-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/drag.c | 26 | ||||
-rw-r--r-- | sway/config/input.c | 4 | ||||
-rw-r--r-- | sway/input/input-manager.c | 7 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/sway-input.5.scd | 3 |
8 files changed, 44 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 1654eb48..bfca6d1e 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -217,6 +217,7 @@ sway_cmd bar_colors_cmd_urgent_workspace; | |||
217 | sway_cmd input_cmd_seat; | 217 | sway_cmd input_cmd_seat; |
218 | sway_cmd input_cmd_accel_profile; | 218 | sway_cmd input_cmd_accel_profile; |
219 | sway_cmd input_cmd_click_method; | 219 | sway_cmd input_cmd_click_method; |
220 | sway_cmd input_cmd_drag; | ||
220 | sway_cmd input_cmd_drag_lock; | 221 | sway_cmd input_cmd_drag_lock; |
221 | sway_cmd input_cmd_dwt; | 222 | sway_cmd input_cmd_dwt; |
222 | sway_cmd input_cmd_events; | 223 | sway_cmd input_cmd_events; |
diff --git a/include/sway/config.h b/include/sway/config.h index af5c7a18..2e532f7e 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -93,6 +93,7 @@ struct input_config { | |||
93 | 93 | ||
94 | int accel_profile; | 94 | int accel_profile; |
95 | int click_method; | 95 | int click_method; |
96 | int drag; | ||
96 | int drag_lock; | 97 | int drag_lock; |
97 | int dwt; | 98 | int dwt; |
98 | int left_handed; | 99 | int left_handed; |
diff --git a/sway/commands/input.c b/sway/commands/input.c index 9091da2a..2889d47d 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c | |||
@@ -9,6 +9,7 @@ | |||
9 | static struct cmd_handler input_handlers[] = { | 9 | static struct cmd_handler input_handlers[] = { |
10 | { "accel_profile", input_cmd_accel_profile }, | 10 | { "accel_profile", input_cmd_accel_profile }, |
11 | { "click_method", input_cmd_click_method }, | 11 | { "click_method", input_cmd_click_method }, |
12 | { "drag", input_cmd_drag }, | ||
12 | { "drag_lock", input_cmd_drag_lock }, | 13 | { "drag_lock", input_cmd_drag_lock }, |
13 | { "dwt", input_cmd_dwt }, | 14 | { "dwt", input_cmd_dwt }, |
14 | { "events", input_cmd_events }, | 15 | { "events", input_cmd_events }, |
diff --git a/sway/commands/input/drag.c b/sway/commands/input/drag.c new file mode 100644 index 00000000..e325df29 --- /dev/null +++ b/sway/commands/input/drag.c | |||
@@ -0,0 +1,26 @@ | |||
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 | #include "util.h" | ||
7 | |||
8 | struct cmd_results *input_cmd_drag(int argc, char **argv) { | ||
9 | struct cmd_results *error = NULL; | ||
10 | if ((error = checkarg(argc, "drag", EXPECTED_AT_LEAST, 1))) { | ||
11 | return error; | ||
12 | } | ||
13 | struct input_config *ic = config->handler_context.input_config; | ||
14 | if (!ic) { | ||
15 | return cmd_results_new(CMD_FAILURE, | ||
16 | "drag", "No input device defined."); | ||
17 | } | ||
18 | |||
19 | if (parse_boolean(argv[0], true)) { | ||
20 | ic->drag = LIBINPUT_CONFIG_DRAG_ENABLED; | ||
21 | } else { | ||
22 | ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED; | ||
23 | } | ||
24 | |||
25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
26 | } | ||
diff --git a/sway/config/input.c b/sway/config/input.c index 6b43a5b9..794d5194 100644 --- a/sway/config/input.c +++ b/sway/config/input.c | |||
@@ -20,6 +20,7 @@ struct input_config *new_input_config(const char* identifier) { | |||
20 | 20 | ||
21 | input->tap = INT_MIN; | 21 | input->tap = INT_MIN; |
22 | input->tap_button_map = INT_MIN; | 22 | input->tap_button_map = INT_MIN; |
23 | input->drag = INT_MIN; | ||
23 | input->drag_lock = INT_MIN; | 24 | input->drag_lock = INT_MIN; |
24 | input->dwt = INT_MIN; | 25 | input->dwt = INT_MIN; |
25 | input->send_events = INT_MIN; | 26 | input->send_events = INT_MIN; |
@@ -46,6 +47,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) { | |||
46 | if (src->click_method != INT_MIN) { | 47 | if (src->click_method != INT_MIN) { |
47 | dst->click_method = src->click_method; | 48 | dst->click_method = src->click_method; |
48 | } | 49 | } |
50 | if (src->drag != INT_MIN) { | ||
51 | dst->drag = src->drag; | ||
52 | } | ||
49 | if (src->drag_lock != INT_MIN) { | 53 | if (src->drag_lock != INT_MIN) { |
50 | dst->drag_lock = src->drag_lock; | 54 | dst->drag_lock = src->drag_lock; |
51 | } | 55 | } |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index f39fe29c..32f0355e 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -120,6 +120,13 @@ static void input_manager_libinput_config_pointer( | |||
120 | libinput_device_config_click_set_method(libinput_device, | 120 | libinput_device_config_click_set_method(libinput_device, |
121 | ic->click_method); | 121 | ic->click_method); |
122 | } | 122 | } |
123 | if (ic->drag != INT_MIN) { | ||
124 | wlr_log(WLR_DEBUG, | ||
125 | "libinput_config_pointer(%s) tap_set_drag_enabled(%d)", | ||
126 | ic->identifier, ic->click_method); | ||
127 | libinput_device_config_tap_set_drag_enabled(libinput_device, | ||
128 | ic->drag); | ||
129 | } | ||
123 | if (ic->drag_lock != INT_MIN) { | 130 | if (ic->drag_lock != INT_MIN) { |
124 | wlr_log(WLR_DEBUG, | 131 | wlr_log(WLR_DEBUG, |
125 | "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", | 132 | "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", |
diff --git a/sway/meson.build b/sway/meson.build index d67a4c64..05a0316a 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -119,6 +119,7 @@ sway_sources = files( | |||
119 | 119 | ||
120 | 'commands/input/accel_profile.c', | 120 | 'commands/input/accel_profile.c', |
121 | 'commands/input/click_method.c', | 121 | 'commands/input/click_method.c', |
122 | 'commands/input/drag.c', | ||
122 | 'commands/input/drag_lock.c', | 123 | 'commands/input/drag_lock.c', |
123 | 'commands/input/dwt.c', | 124 | 'commands/input/dwt.c', |
124 | 'commands/input/events.c', | 125 | 'commands/input/events.c', |
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index 707c36af..4fe7e7b7 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd | |||
@@ -68,6 +68,9 @@ The following commands may only be used in the configuration file. | |||
68 | *input* <identifier> click\_method none|button\_areas|clickfinger | 68 | *input* <identifier> click\_method none|button\_areas|clickfinger |
69 | Changes the click method for the specified device. | 69 | Changes the click method for the specified device. |
70 | 70 | ||
71 | *input* <identifier> drag enabled|disabled | ||
72 | Enables or disables tap-and-drag for specified input device. | ||
73 | |||
71 | *input* <identifier> drag\_lock enabled|disabled | 74 | *input* <identifier> drag\_lock enabled|disabled |
72 | Enables or disables drag lock for specified input device. | 75 | Enables or disables drag lock for specified input device. |
73 | 76 | ||