Merge pull request #2725 from PumbaPe/add-tap-and-drag

Add tap and drag to sway-input
This commit is contained in:
Drew DeVault 2018-09-30 13:44:11 +02:00 committed by GitHub
commit 8f6aca2166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 0 deletions

View file

@ -217,6 +217,7 @@ sway_cmd bar_colors_cmd_urgent_workspace;
sway_cmd input_cmd_seat; sway_cmd input_cmd_seat;
sway_cmd input_cmd_accel_profile; sway_cmd input_cmd_accel_profile;
sway_cmd input_cmd_click_method; sway_cmd input_cmd_click_method;
sway_cmd input_cmd_drag;
sway_cmd input_cmd_drag_lock; sway_cmd input_cmd_drag_lock;
sway_cmd input_cmd_dwt; sway_cmd input_cmd_dwt;
sway_cmd input_cmd_events; sway_cmd input_cmd_events;

View file

@ -93,6 +93,7 @@ struct input_config {
int accel_profile; int accel_profile;
int click_method; int click_method;
int drag;
int drag_lock; int drag_lock;
int dwt; int dwt;
int left_handed; int left_handed;

View file

@ -9,6 +9,7 @@
static struct cmd_handler input_handlers[] = { static struct cmd_handler input_handlers[] = {
{ "accel_profile", input_cmd_accel_profile }, { "accel_profile", input_cmd_accel_profile },
{ "click_method", input_cmd_click_method }, { "click_method", input_cmd_click_method },
{ "drag", input_cmd_drag },
{ "drag_lock", input_cmd_drag_lock }, { "drag_lock", input_cmd_drag_lock },
{ "dwt", input_cmd_dwt }, { "dwt", input_cmd_dwt },
{ "events", input_cmd_events }, { "events", input_cmd_events },

View file

@ -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);
}

View file

@ -20,6 +20,7 @@ struct input_config *new_input_config(const char* identifier) {
input->tap = INT_MIN; input->tap = INT_MIN;
input->tap_button_map = INT_MIN; input->tap_button_map = INT_MIN;
input->drag = INT_MIN;
input->drag_lock = INT_MIN; input->drag_lock = INT_MIN;
input->dwt = INT_MIN; input->dwt = INT_MIN;
input->send_events = 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) { if (src->click_method != INT_MIN) {
dst->click_method = src->click_method; dst->click_method = src->click_method;
} }
if (src->drag != INT_MIN) {
dst->drag = src->drag;
}
if (src->drag_lock != INT_MIN) { if (src->drag_lock != INT_MIN) {
dst->drag_lock = src->drag_lock; dst->drag_lock = src->drag_lock;
} }

View file

@ -120,6 +120,13 @@ static void input_manager_libinput_config_pointer(
libinput_device_config_click_set_method(libinput_device, libinput_device_config_click_set_method(libinput_device,
ic->click_method); 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) { if (ic->drag_lock != INT_MIN) {
wlr_log(WLR_DEBUG, wlr_log(WLR_DEBUG,
"libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",

View file

@ -119,6 +119,7 @@ sway_sources = files(
'commands/input/accel_profile.c', 'commands/input/accel_profile.c',
'commands/input/click_method.c', 'commands/input/click_method.c',
'commands/input/drag.c',
'commands/input/drag_lock.c', 'commands/input/drag_lock.c',
'commands/input/dwt.c', 'commands/input/dwt.c',
'commands/input/events.c', 'commands/input/events.c',

View file

@ -67,6 +67,9 @@ The following commands may only be used in the configuration file.
*input* <identifier> click\_method none|button\_areas|clickfinger *input* <identifier> click\_method none|button\_areas|clickfinger
Changes the click method for the specified device. 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 *input* <identifier> drag\_lock enabled|disabled
Enables or disables drag lock for specified input device. Enables or disables drag lock for specified input device.