mirror of
https://github.com/NickHu/sway
synced 2024-12-26 21:58:30 +01:00
Merge pull request #2725 from PumbaPe/add-tap-and-drag
Add tap and drag to sway-input
This commit is contained in:
commit
8f6aca2166
8 changed files with 44 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -93,6 +93,7 @@ struct input_config {
|
|||
|
||||
int accel_profile;
|
||||
int click_method;
|
||||
int drag;
|
||||
int drag_lock;
|
||||
int dwt;
|
||||
int left_handed;
|
||||
|
|
|
@ -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 },
|
||||
|
|
26
sway/commands/input/drag.c
Normal file
26
sway/commands/input/drag.c
Normal 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);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)",
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -67,6 +67,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.
|
||||
|
||||
|
|
Loading…
Reference in a new issue