diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-05-01 07:15:17 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-05-01 07:15:17 -0400 |
commit | f7869d815a17b062f867478ceacc8c1d1cbac6c2 (patch) | |
tree | 2e2ac142780cd6689635c6ce37917d6eb39d2007 | |
parent | Merge pull request #619 from mikkeloscar/fix-workspace-pr (diff) | |
parent | Add input cmd for setting pointer accel profile. (diff) | |
download | sway-f7869d815a17b062f867478ceacc8c1d1cbac6c2.tar.gz sway-f7869d815a17b062f867478ceacc8c1d1cbac6c2.tar.zst sway-f7869d815a17b062f867478ceacc8c1d1cbac6c2.zip |
Merge pull request #624 from tajjada/add-input-accel-profile
Add input cmd for setting pointer accel profile.
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | sway/commands.c | 30 | ||||
-rw-r--r-- | sway/config.c | 7 | ||||
-rw-r--r-- | sway/input.c | 1 | ||||
-rw-r--r-- | sway/sway-input.5.txt | 3 |
5 files changed, 41 insertions, 2 deletions
diff --git a/include/config.h b/include/config.h index 37b97665..8e5e33c3 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -52,6 +52,8 @@ struct sway_mode { | |||
52 | */ | 52 | */ |
53 | struct input_config { | 53 | struct input_config { |
54 | char *identifier; | 54 | char *identifier; |
55 | |||
56 | int accel_profile; | ||
55 | int click_method; | 57 | int click_method; |
56 | int drag_lock; | 58 | int drag_lock; |
57 | int dwt; | 59 | int dwt; |
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) { | |||
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | static struct cmd_results *input_cmd_accel_profile(int argc, char **argv) { | ||
1153 | struct cmd_results *error = NULL; | ||
1154 | if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) { | ||
1155 | return error; | ||
1156 | } | ||
1157 | if (!current_input_config) { | ||
1158 | return cmd_results_new(CMD_FAILURE, "accel_profile", "No input device defined."); | ||
1159 | } | ||
1160 | struct input_config *new_config = new_input_config(current_input_config->identifier); | ||
1161 | |||
1162 | if (strcasecmp(argv[0], "adaptive") == 0) { | ||
1163 | new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; | ||
1164 | } else if (strcasecmp(argv[0], "flat") == 0) { | ||
1165 | new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; | ||
1166 | } else { | ||
1167 | return cmd_results_new(CMD_INVALID, "accel_profile", | ||
1168 | "Expected 'accel_profile <adaptive|flat>'"); | ||
1169 | } | ||
1170 | |||
1171 | input_cmd_apply(new_config); | ||
1172 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
1173 | } | ||
1174 | |||
1152 | static struct cmd_results *input_cmd_click_method(int argc, char **argv) { | 1175 | static struct cmd_results *input_cmd_click_method(int argc, char **argv) { |
1153 | sway_log(L_DEBUG, "click_method for device: %d %s", current_input_config==NULL, current_input_config->identifier); | 1176 | sway_log(L_DEBUG, "click_method for device: %d %s", current_input_config==NULL, current_input_config->identifier); |
1154 | struct cmd_results *error = NULL; | 1177 | struct cmd_results *error = NULL; |
@@ -1388,7 +1411,9 @@ static struct cmd_results *cmd_input(int argc, char **argv) { | |||
1388 | 1411 | ||
1389 | struct cmd_results *res; | 1412 | struct cmd_results *res; |
1390 | current_input_config = new_input_config(argv[0]); | 1413 | current_input_config = new_input_config(argv[0]); |
1391 | if (strcasecmp("click_method", argv[1]) == 0) { | 1414 | if (strcasecmp("accel_profile", argv[1]) == 0) { |
1415 | res = input_cmd_accel_profile(argc_new, argv_new); | ||
1416 | } else if (strcasecmp("click_method", argv[1]) == 0) { | ||
1392 | res = input_cmd_click_method(argc_new, argv_new); | 1417 | res = input_cmd_click_method(argc_new, argv_new); |
1393 | } else if (strcasecmp("drag_lock", argv[1]) == 0) { | 1418 | } else if (strcasecmp("drag_lock", argv[1]) == 0) { |
1394 | res = input_cmd_drag_lock(argc_new, argv_new); | 1419 | res = input_cmd_drag_lock(argc_new, argv_new); |
@@ -1407,7 +1432,7 @@ static struct cmd_results *cmd_input(int argc, char **argv) { | |||
1407 | } else if (strcasecmp("tap", argv[1]) == 0) { | 1432 | } else if (strcasecmp("tap", argv[1]) == 0) { |
1408 | res = input_cmd_tap(argc_new, argv_new); | 1433 | res = input_cmd_tap(argc_new, argv_new); |
1409 | } else { | 1434 | } else { |
1410 | res = cmd_results_new(CMD_INVALID, "input <device>", "Unknonwn command %s", argv[1]); | 1435 | res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]); |
1411 | } | 1436 | } |
1412 | current_input_config = NULL; | 1437 | current_input_config = NULL; |
1413 | return res; | 1438 | return res; |
@@ -3127,6 +3152,7 @@ static struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv | |||
3127 | } | 3152 | } |
3128 | 3153 | ||
3129 | static struct cmd_handler input_handlers[] = { | 3154 | static struct cmd_handler input_handlers[] = { |
3155 | { "accel_profile", input_cmd_accel_profile }, | ||
3130 | { "click_method", input_cmd_click_method }, | 3156 | { "click_method", input_cmd_click_method }, |
3131 | { "drag_lock", input_cmd_drag_lock }, | 3157 | { "drag_lock", input_cmd_drag_lock }, |
3132 | { "dwt", input_cmd_dwt }, | 3158 | { "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) { | |||
562 | } | 562 | } |
563 | dst->identifier = strdup(src->identifier); | 563 | dst->identifier = strdup(src->identifier); |
564 | } | 564 | } |
565 | if (src->accel_profile != INT_MIN) { | ||
566 | dst->accel_profile = src->accel_profile; | ||
567 | } | ||
565 | if (src->click_method != INT_MIN) { | 568 | if (src->click_method != INT_MIN) { |
566 | dst->click_method = src->click_method; | 569 | dst->click_method = src->click_method; |
567 | } | 570 | } |
@@ -735,6 +738,10 @@ void apply_input_config(struct input_config *ic, struct libinput_device *dev) { | |||
735 | ic->identifier); | 738 | ic->identifier); |
736 | } | 739 | } |
737 | 740 | ||
741 | if (ic && ic->accel_profile != INT_MIN) { | ||
742 | sway_log(L_DEBUG, "apply_input_config(%s) accel_set_profile(%d)", ic->identifier, ic->accel_profile); | ||
743 | libinput_device_config_accel_set_profile(dev, ic->accel_profile); | ||
744 | } | ||
738 | if (ic && ic->click_method != INT_MIN) { | 745 | if (ic && ic->click_method != INT_MIN) { |
739 | sway_log(L_DEBUG, "apply_input_config(%s) click_set_method(%d)", ic->identifier, ic->click_method); | 746 | sway_log(L_DEBUG, "apply_input_config(%s) click_set_method(%d)", ic->identifier, ic->click_method); |
740 | libinput_device_config_click_set_method(dev, ic->click_method); | 747 | 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) { | |||
21 | input->click_method = INT_MIN; | 21 | input->click_method = INT_MIN; |
22 | input->middle_emulation = INT_MIN; | 22 | input->middle_emulation = INT_MIN; |
23 | input->natural_scroll = INT_MIN; | 23 | input->natural_scroll = INT_MIN; |
24 | input->accel_profile = INT_MIN; | ||
24 | input->pointer_accel = FLT_MIN; | 25 | input->pointer_accel = FLT_MIN; |
25 | input->scroll_method = INT_MIN; | 26 | input->scroll_method = INT_MIN; |
26 | 27 | ||
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. | |||
17 | Commands | 17 | Commands |
18 | -------- | 18 | -------- |
19 | 19 | ||
20 | **input** <identifier> accel_profile <adaptive|flat>:: | ||
21 | Sets the pointer acceleration profile for the specified input device. | ||
22 | |||
20 | **input** <identifier> click_method <none|button_areas|clickfinger>:: | 23 | **input** <identifier> click_method <none|button_areas|clickfinger>:: |
21 | Changes the click method for the specified device. | 24 | Changes the click method for the specified device. |
22 | 25 | ||