aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPP <34623266+PumbaPe@users.noreply.github.com>2018-09-29 11:49:41 +0200
committerPP <34623266+PumbaPe@users.noreply.github.com>2018-09-29 11:49:41 +0200
commitae2b70f59ec988ae1ad108316ec04d1f634ec735 (patch)
treedcd6007eede8002b9b2306311a6ec4cc19b2bdd6
parentca7084cb52bd5a27a847e43320490b7a5ee5ef73 (diff)
add tap-and-drag setting to sway-input
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h1
-rw-r--r--sway/commands/input.c1
-rw-r--r--sway/commands/input/drag.c26
-rw-r--r--sway/config/input.c4
-rw-r--r--sway/input/input-manager.c7
-rw-r--r--sway/meson.build1
-rw-r--r--sway/sway-input.5.scd3
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;
sway_cmd input_cmd_seat;
sway_cmd input_cmd_accel_profile;
sway_cmd input_cmd_click_method;
+sway_cmd input_cmd_drag;
sway_cmd input_cmd_drag_lock;
sway_cmd input_cmd_dwt;
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 {
int accel_profile;
int click_method;
+ int drag;
int drag_lock;
int dwt;
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 @@
static struct cmd_handler input_handlers[] = {
{ "accel_profile", input_cmd_accel_profile },
{ "click_method", input_cmd_click_method },
+ { "drag", input_cmd_drag },
{ "drag_lock", input_cmd_drag_lock },
{ "dwt", input_cmd_dwt },
{ "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 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/config.h"
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+#include "util.h"
+
+struct cmd_results *input_cmd_drag(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "drag", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ struct input_config *ic = config->handler_context.input_config;
+ if (!ic) {
+ return cmd_results_new(CMD_FAILURE,
+ "drag", "No input device defined.");
+ }
+
+ if (parse_boolean(argv[0], true)) {
+ ic->drag = LIBINPUT_CONFIG_DRAG_ENABLED;
+ } else {
+ ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED;
+ }
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
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) {
input->tap = INT_MIN;
input->tap_button_map = INT_MIN;
+ input->drag = INT_MIN;
input->drag_lock = INT_MIN;
input->dwt = INT_MIN;
input->send_events = INT_MIN;
@@ -46,6 +47,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
if (src->click_method != INT_MIN) {
dst->click_method = src->click_method;
}
+ if (src->drag != INT_MIN) {
+ dst->drag = src->drag;
+ }
if (src->drag_lock != INT_MIN) {
dst->drag_lock = src->drag_lock;
}
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(
libinput_device_config_click_set_method(libinput_device,
ic->click_method);
}
+ if (ic->drag != INT_MIN) {
+ wlr_log(WLR_DEBUG,
+ "libinput_config_pointer(%s) tap_set_drag_enabled(%d)",
+ ic->identifier, ic->click_method);
+ libinput_device_config_tap_set_drag_enabled(libinput_device,
+ ic->drag);
+ }
if (ic->drag_lock != INT_MIN) {
wlr_log(WLR_DEBUG,
"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(
'commands/input/accel_profile.c',
'commands/input/click_method.c',
+ 'commands/input/drag.c',
'commands/input/drag_lock.c',
'commands/input/dwt.c',
'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.
*input* <identifier> click\_method none|button\_areas|clickfinger
Changes the click method for the specified device.
+*input* <identifier> drag enabled|disabled
+ Enables or disables tap-and-drag for specified input device.
+
*input* <identifier> drag\_lock enabled|disabled
Enables or disables drag lock for specified input device.