diff options
-rw-r--r-- | include/sway/commands.h | 2 | ||||
-rw-r--r-- | include/sway/config.h | 2 | ||||
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/commands/input.c | 4 | ||||
-rw-r--r-- | sway/commands/input/repeat_delay.c | 30 | ||||
-rw-r--r-- | sway/commands/input/repeat_rate.c | 30 | ||||
-rw-r--r-- | sway/config/input.c | 8 | ||||
-rw-r--r-- | sway/input/keyboard.c | 9 | ||||
-rw-r--r-- | sway/meson.build | 2 | ||||
-rw-r--r-- | sway/sway-input.5.txt | 6 |
10 files changed, 94 insertions, 1 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index dbebaa49..7b8c949b 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -196,6 +196,8 @@ sway_cmd input_cmd_map_to_output; sway_cmd input_cmd_middle_emulation; sway_cmd input_cmd_natural_scroll; sway_cmd input_cmd_pointer_accel; +sway_cmd input_cmd_repeat_delay; +sway_cmd input_cmd_repeat_rate; sway_cmd input_cmd_scroll_method; sway_cmd input_cmd_tap; sway_cmd input_cmd_xkb_layout; diff --git a/include/sway/config.h b/include/sway/config.h index ed49fbbd..085f7b92 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -65,6 +65,8 @@ struct input_config { int middle_emulation; int natural_scroll; float pointer_accel; + int repeat_delay; + int repeat_rate; int scroll_method; int send_events; int tap; diff --git a/sway/commands.c b/sway/commands.c index 99f42524..fb3eaa75 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -191,6 +191,8 @@ static struct cmd_handler input_handlers[] = { { "middle_emulation", input_cmd_middle_emulation }, { "natural_scroll", input_cmd_natural_scroll }, { "pointer_accel", input_cmd_pointer_accel }, + { "repeat_delay", input_cmd_repeat_delay }, + { "repeat_rate", input_cmd_repeat_rate }, { "scroll_method", input_cmd_scroll_method }, { "tap", input_cmd_tap }, { "xkb_layout", input_cmd_xkb_layout }, diff --git a/sway/commands/input.c b/sway/commands/input.c index fa9cf05a..eeb4ee75 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c @@ -55,6 +55,10 @@ struct cmd_results *cmd_input(int argc, char **argv) { res = input_cmd_natural_scroll(argc_new, argv_new); } else if (strcasecmp("pointer_accel", argv[1]) == 0) { res = input_cmd_pointer_accel(argc_new, argv_new); + } else if (strcasecmp("repeat_delay", argv[1]) == 0) { + res = input_cmd_repeat_delay(argc_new, argv_new); + } else if (strcasecmp("repeat_rate", argv[1]) == 0) { + res = input_cmd_repeat_rate(argc_new, argv_new); } else if (strcasecmp("scroll_method", argv[1]) == 0) { res = input_cmd_scroll_method(argc_new, argv_new); } else if (strcasecmp("tap", argv[1]) == 0) { diff --git a/sway/commands/input/repeat_delay.c b/sway/commands/input/repeat_delay.c new file mode 100644 index 00000000..ce265841 --- /dev/null +++ b/sway/commands/input/repeat_delay.c @@ -0,0 +1,30 @@ +#include <stdlib.h> +#include <string.h> +#include "sway/config.h" +#include "sway/commands.h" +#include "sway/input/input-manager.h" + +struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "repeat_delay", EXPECTED_EQUAL_TO, 1))) { + return error; + } + struct input_config *current_input_config = + config->handler_context.input_config; + if (!current_input_config) { + return cmd_results_new(CMD_FAILURE, + "repeat_delay", "No input device defined."); + } + struct input_config *new_config = + new_input_config(current_input_config->identifier); + + int repeat_delay = atoi(argv[0]); + if (repeat_delay < 0) { + return cmd_results_new(CMD_INVALID, "repeat_delay", + "Repeat delay cannot be negative"); + } + new_config->repeat_delay = repeat_delay; + + apply_input_config(new_config); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/commands/input/repeat_rate.c b/sway/commands/input/repeat_rate.c new file mode 100644 index 00000000..f2ea2e69 --- /dev/null +++ b/sway/commands/input/repeat_rate.c @@ -0,0 +1,30 @@ +#include <stdlib.h> +#include <string.h> +#include "sway/config.h" +#include "sway/commands.h" +#include "sway/input/input-manager.h" + +struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "repeat_rate", EXPECTED_EQUAL_TO, 1))) { + return error; + } + struct input_config *current_input_config = + config->handler_context.input_config; + if (!current_input_config) { + return cmd_results_new(CMD_FAILURE, + "repeat_rate", "No input device defined."); + } + struct input_config *new_config = + new_input_config(current_input_config->identifier); + + int repeat_rate = atoi(argv[0]); + if (repeat_rate < 0) { + return cmd_results_new(CMD_INVALID, "repeat_rate", + "Repeat rate cannot be negative"); + } + new_config->repeat_rate = repeat_rate; + + apply_input_config(new_config); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/config/input.c b/sway/config/input.c index 5e657c43..a9f20723 100644 --- a/sway/config/input.c +++ b/sway/config/input.c @@ -29,6 +29,8 @@ struct input_config *new_input_config(const char* identifier) { input->pointer_accel = FLT_MIN; input->scroll_method = INT_MIN; input->left_handed = INT_MIN; + input->repeat_delay = INT_MIN; + input->repeat_rate = INT_MIN; return input; } @@ -59,6 +61,12 @@ void merge_input_config(struct input_config *dst, struct input_config *src) { if (src->pointer_accel != FLT_MIN) { dst->pointer_accel = src->pointer_accel; } + if (src->repeat_delay != INT_MIN) { + dst->repeat_delay = src->repeat_delay; + } + if (src->repeat_rate != INT_MIN) { + dst->repeat_rate = src->repeat_rate; + } if (src->scroll_method != INT_MIN) { dst->scroll_method = src->scroll_method; } diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index dbb0c359..dbf2ce01 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -1,4 +1,5 @@ #include <assert.h> +#include <limits.h> #include <wlr/backend/multi.h> #include <wlr/backend/session.h> #include "sway/input/seat.h" @@ -479,7 +480,13 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { keyboard->keymap = keymap; wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap); - wlr_keyboard_set_repeat_info(wlr_device->keyboard, 25, 600); + if (input_config && input_config->repeat_delay != INT_MIN + && input_config->repeat_rate != INT_MIN) { + wlr_keyboard_set_repeat_info(wlr_device->keyboard, + input_config->repeat_rate, input_config->repeat_delay); + } else { + wlr_keyboard_set_repeat_info(wlr_device->keyboard, 25, 600); + } xkb_context_unref(context); struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat; wlr_seat_set_keyboard(seat, wlr_device); diff --git a/sway/meson.build b/sway/meson.build index 9e55e335..4ceb07b4 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -90,6 +90,8 @@ sway_sources = files( 'commands/input/middle_emulation.c', 'commands/input/natural_scroll.c', 'commands/input/pointer_accel.c', + 'commands/input/repeat_delay.c', + 'commands/input/repeat_rate.c', 'commands/input/scroll_method.c', 'commands/input/tap.c', 'commands/input/xkb_layout.c', diff --git a/sway/sway-input.5.txt b/sway/sway-input.5.txt index 05725360..948b4b6f 100644 --- a/sway/sway-input.5.txt +++ b/sway/sway-input.5.txt @@ -92,6 +92,12 @@ Libinput Configuration **input** <identifier> pointer_accel <[-1,1]>:: Changes the pointer acceleration for the specified input device. +**input** <identifier> repeat_delay <milliseconds>:: + Sets the amount of time a key must be held before it starts repeating. + +**input** <identifier> repeat_rate <characters per second>:: + Sets the frequency of key repeats once the repeat_delay has passed. + **input** <identifier> scroll_method <none|two_finger|edge|on_button_down>:: Changes the scroll method for the specified input device. |