Make key repeat configurable
This creates two input commands for configuring the repeat delay and rate. Example config: input "myidentifier" { repeat_delay 250 repeat_rate 25 }
This commit is contained in:
parent
d668d57892
commit
5b30391383
|
@ -196,6 +196,8 @@ sway_cmd input_cmd_map_to_output;
|
||||||
sway_cmd input_cmd_middle_emulation;
|
sway_cmd input_cmd_middle_emulation;
|
||||||
sway_cmd input_cmd_natural_scroll;
|
sway_cmd input_cmd_natural_scroll;
|
||||||
sway_cmd input_cmd_pointer_accel;
|
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_scroll_method;
|
||||||
sway_cmd input_cmd_tap;
|
sway_cmd input_cmd_tap;
|
||||||
sway_cmd input_cmd_xkb_layout;
|
sway_cmd input_cmd_xkb_layout;
|
||||||
|
|
|
@ -65,6 +65,8 @@ struct input_config {
|
||||||
int middle_emulation;
|
int middle_emulation;
|
||||||
int natural_scroll;
|
int natural_scroll;
|
||||||
float pointer_accel;
|
float pointer_accel;
|
||||||
|
int repeat_delay;
|
||||||
|
int repeat_rate;
|
||||||
int scroll_method;
|
int scroll_method;
|
||||||
int send_events;
|
int send_events;
|
||||||
int tap;
|
int tap;
|
||||||
|
|
|
@ -191,6 +191,8 @@ static struct cmd_handler input_handlers[] = {
|
||||||
{ "middle_emulation", input_cmd_middle_emulation },
|
{ "middle_emulation", input_cmd_middle_emulation },
|
||||||
{ "natural_scroll", input_cmd_natural_scroll },
|
{ "natural_scroll", input_cmd_natural_scroll },
|
||||||
{ "pointer_accel", input_cmd_pointer_accel },
|
{ "pointer_accel", input_cmd_pointer_accel },
|
||||||
|
{ "repeat_delay", input_cmd_repeat_delay },
|
||||||
|
{ "repeat_rate", input_cmd_repeat_rate },
|
||||||
{ "scroll_method", input_cmd_scroll_method },
|
{ "scroll_method", input_cmd_scroll_method },
|
||||||
{ "tap", input_cmd_tap },
|
{ "tap", input_cmd_tap },
|
||||||
{ "xkb_layout", input_cmd_xkb_layout },
|
{ "xkb_layout", input_cmd_xkb_layout },
|
||||||
|
|
|
@ -55,6 +55,10 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
||||||
res = input_cmd_natural_scroll(argc_new, argv_new);
|
res = input_cmd_natural_scroll(argc_new, argv_new);
|
||||||
} else if (strcasecmp("pointer_accel", argv[1]) == 0) {
|
} else if (strcasecmp("pointer_accel", argv[1]) == 0) {
|
||||||
res = input_cmd_pointer_accel(argc_new, argv_new);
|
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) {
|
} else if (strcasecmp("scroll_method", argv[1]) == 0) {
|
||||||
res = input_cmd_scroll_method(argc_new, argv_new);
|
res = input_cmd_scroll_method(argc_new, argv_new);
|
||||||
} else if (strcasecmp("tap", argv[1]) == 0) {
|
} else if (strcasecmp("tap", argv[1]) == 0) {
|
||||||
|
|
55
sway/commands/input/repeat.c
Normal file
55
sway/commands/input/repeat.c
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
|
@ -29,6 +29,8 @@ struct input_config *new_input_config(const char* identifier) {
|
||||||
input->pointer_accel = FLT_MIN;
|
input->pointer_accel = FLT_MIN;
|
||||||
input->scroll_method = INT_MIN;
|
input->scroll_method = INT_MIN;
|
||||||
input->left_handed = INT_MIN;
|
input->left_handed = INT_MIN;
|
||||||
|
input->repeat_delay = INT_MIN;
|
||||||
|
input->repeat_rate = INT_MIN;
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
@ -59,6 +61,12 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
|
||||||
if (src->pointer_accel != FLT_MIN) {
|
if (src->pointer_accel != FLT_MIN) {
|
||||||
dst->pointer_accel = src->pointer_accel;
|
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) {
|
if (src->scroll_method != INT_MIN) {
|
||||||
dst->scroll_method = src->scroll_method;
|
dst->scroll_method = src->scroll_method;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <wlr/backend/multi.h>
|
#include <wlr/backend/multi.h>
|
||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
|
@ -479,7 +480,13 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
||||||
keyboard->keymap = keymap;
|
keyboard->keymap = keymap;
|
||||||
wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->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);
|
xkb_context_unref(context);
|
||||||
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
|
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
|
||||||
wlr_seat_set_keyboard(seat, wlr_device);
|
wlr_seat_set_keyboard(seat, wlr_device);
|
||||||
|
|
|
@ -90,6 +90,7 @@ sway_sources = files(
|
||||||
'commands/input/middle_emulation.c',
|
'commands/input/middle_emulation.c',
|
||||||
'commands/input/natural_scroll.c',
|
'commands/input/natural_scroll.c',
|
||||||
'commands/input/pointer_accel.c',
|
'commands/input/pointer_accel.c',
|
||||||
|
'commands/input/repeat.c',
|
||||||
'commands/input/scroll_method.c',
|
'commands/input/scroll_method.c',
|
||||||
'commands/input/tap.c',
|
'commands/input/tap.c',
|
||||||
'commands/input/xkb_layout.c',
|
'commands/input/xkb_layout.c',
|
||||||
|
|
|
@ -92,6 +92,12 @@ Libinput Configuration
|
||||||
**input** <identifier> pointer_accel <[-1,1]>::
|
**input** <identifier> pointer_accel <[-1,1]>::
|
||||||
Changes the pointer acceleration for the specified input device.
|
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 <milliseconds>::
|
||||||
|
Sets the frequency of key repeats once the repeat_delay has passed.
|
||||||
|
|
||||||
**input** <identifier> scroll_method <none|two_finger|edge|on_button_down>::
|
**input** <identifier> scroll_method <none|two_finger|edge|on_button_down>::
|
||||||
Changes the scroll method for the specified input device.
|
Changes the scroll method for the specified input device.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue