aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-05-01 07:15:17 -0400
committerDrew DeVault <sir@cmpwn.com>2016-05-01 07:15:17 -0400
commitf7869d815a17b062f867478ceacc8c1d1cbac6c2 (patch)
tree2e2ac142780cd6689635c6ce37917d6eb39d2007 /sway
parent68f0baf3ec3846e4f0ac7cecc12ed5ae9ad68546 (diff)
parentde007c9b58fa5fda767196321a72dc9a39609efb (diff)
Merge pull request #624 from tajjada/add-input-accel-profile
Add input cmd for setting pointer accel profile.
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c30
-rw-r--r--sway/config.c7
-rw-r--r--sway/input.c1
-rw-r--r--sway/sway-input.5.txt3
4 files changed, 39 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 332d3888..79591925 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1149,6 +1149,29 @@ static void input_cmd_apply(struct input_config *input) {
}
}
+static struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "accel_profile", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "adaptive") == 0) {
+ new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
+ } else if (strcasecmp(argv[0], "flat") == 0) {
+ new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
+ } else {
+ return cmd_results_new(CMD_INVALID, "accel_profile",
+ "Expected 'accel_profile <adaptive|flat>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
+
static struct cmd_results *input_cmd_click_method(int argc, char **argv) {
sway_log(L_DEBUG, "click_method for device: %d %s", current_input_config==NULL, current_input_config->identifier);
struct cmd_results *error = NULL;
@@ -1388,7 +1411,9 @@ static struct cmd_results *cmd_input(int argc, char **argv) {
struct cmd_results *res;
current_input_config = new_input_config(argv[0]);
- if (strcasecmp("click_method", argv[1]) == 0) {
+ if (strcasecmp("accel_profile", argv[1]) == 0) {
+ res = input_cmd_accel_profile(argc_new, argv_new);
+ } else if (strcasecmp("click_method", argv[1]) == 0) {
res = input_cmd_click_method(argc_new, argv_new);
} else if (strcasecmp("drag_lock", argv[1]) == 0) {
res = input_cmd_drag_lock(argc_new, argv_new);
@@ -1407,7 +1432,7 @@ static struct cmd_results *cmd_input(int argc, char **argv) {
} else if (strcasecmp("tap", argv[1]) == 0) {
res = input_cmd_tap(argc_new, argv_new);
} else {
- res = cmd_results_new(CMD_INVALID, "input <device>", "Unknonwn command %s", argv[1]);
+ res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]);
}
current_input_config = NULL;
return res;
@@ -3127,6 +3152,7 @@ static struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv
}
static struct cmd_handler input_handlers[] = {
+ { "accel_profile", input_cmd_accel_profile },
{ "click_method", input_cmd_click_method },
{ "drag_lock", input_cmd_drag_lock },
{ "dwt", input_cmd_dwt },
diff --git a/sway/config.c b/sway/config.c
index b3b743c3..69ae7c03 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -562,6 +562,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
}
dst->identifier = strdup(src->identifier);
}
+ if (src->accel_profile != INT_MIN) {
+ dst->accel_profile = src->accel_profile;
+ }
if (src->click_method != INT_MIN) {
dst->click_method = src->click_method;
}
@@ -735,6 +738,10 @@ void apply_input_config(struct input_config *ic, struct libinput_device *dev) {
ic->identifier);
}
+ if (ic && ic->accel_profile != INT_MIN) {
+ sway_log(L_DEBUG, "apply_input_config(%s) accel_set_profile(%d)", ic->identifier, ic->accel_profile);
+ libinput_device_config_accel_set_profile(dev, ic->accel_profile);
+ }
if (ic && ic->click_method != INT_MIN) {
sway_log(L_DEBUG, "apply_input_config(%s) click_set_method(%d)", ic->identifier, ic->click_method);
libinput_device_config_click_set_method(dev, ic->click_method);
diff --git a/sway/input.c b/sway/input.c
index fe0d1aff..1f3e99e7 100644
--- a/sway/input.c
+++ b/sway/input.c
@@ -21,6 +21,7 @@ struct input_config *new_input_config(const char* identifier) {
input->click_method = INT_MIN;
input->middle_emulation = INT_MIN;
input->natural_scroll = INT_MIN;
+ input->accel_profile = INT_MIN;
input->pointer_accel = FLT_MIN;
input->scroll_method = INT_MIN;
diff --git a/sway/sway-input.5.txt b/sway/sway-input.5.txt
index 05dcbeef..c2637830 100644
--- a/sway/sway-input.5.txt
+++ b/sway/sway-input.5.txt
@@ -17,6 +17,9 @@ your config file.
Commands
--------
+**input** <identifier> accel_profile <adaptive|flat>::
+ Sets the pointer acceleration profile for the specified input device.
+
**input** <identifier> click_method <none|button_areas|clickfinger>::
Changes the click method for the specified device.