mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Bindings use advised keyboard repeat parameters
Now 'repeat_delay' and 'repeat_rate' control the initial delay and rate (per second) of repeated binding invocations. If the repeat delay is zero, binding repetition is disabled. When the repeat rate is zero, the binding is repeated exactly once, assuming no other key events intervene.
This commit is contained in:
parent
e33dfbfa75
commit
8dbbfa5965
2 changed files with 10 additions and 10 deletions
|
@ -41,8 +41,6 @@ struct sway_keyboard {
|
||||||
|
|
||||||
struct wl_event_source *key_repeat_source;
|
struct wl_event_source *key_repeat_source;
|
||||||
struct sway_binding *repeat_binding;
|
struct sway_binding *repeat_binding;
|
||||||
int key_repeat_initial_delay; // first key repeat event delay, in ms
|
|
||||||
int key_repeat_step_delay; // subsequent repeat delay, in ms
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
|
struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
|
||||||
|
|
|
@ -285,10 +285,10 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up (or clear) keyboard repeat for a pressed binding
|
// Set up (or clear) keyboard repeat for a pressed binding
|
||||||
if (next_repeat_binding) {
|
if (next_repeat_binding && wlr_device->keyboard->repeat_info.delay > 0) {
|
||||||
keyboard->repeat_binding = next_repeat_binding;
|
keyboard->repeat_binding = next_repeat_binding;
|
||||||
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
||||||
keyboard->key_repeat_initial_delay) < 0) {
|
wlr_device->keyboard->repeat_info.delay) < 0) {
|
||||||
wlr_log(WLR_DEBUG, "failed to set key repeat timer");
|
wlr_log(WLR_DEBUG, "failed to set key repeat timer");
|
||||||
}
|
}
|
||||||
} else if (keyboard->repeat_binding) {
|
} else if (keyboard->repeat_binding) {
|
||||||
|
@ -321,12 +321,16 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
static int handle_keyboard_repeat(void *data) {
|
static int handle_keyboard_repeat(void *data) {
|
||||||
struct sway_keyboard *keyboard = (struct sway_keyboard *)data;
|
struct sway_keyboard *keyboard = (struct sway_keyboard *)data;
|
||||||
|
struct wlr_keyboard *wlr_device =
|
||||||
|
keyboard->seat_device->input_device->wlr_device->keyboard;
|
||||||
if (keyboard->repeat_binding) {
|
if (keyboard->repeat_binding) {
|
||||||
|
if (wlr_device->repeat_info.rate > 0) {
|
||||||
// We queue the next event first, as the command might cancel it
|
// We queue the next event first, as the command might cancel it
|
||||||
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
if (wl_event_source_timer_update(keyboard->key_repeat_source,
|
||||||
keyboard->key_repeat_step_delay) < 0) {
|
1000 / wlr_device->repeat_info.rate) < 0) {
|
||||||
wlr_log(WLR_DEBUG, "failed to update key repeat timer");
|
wlr_log(WLR_DEBUG, "failed to update key repeat timer");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
seat_execute_command(keyboard->seat_device->sway_seat,
|
seat_execute_command(keyboard->seat_device->sway_seat,
|
||||||
keyboard->repeat_binding);
|
keyboard->repeat_binding);
|
||||||
|
@ -362,8 +366,6 @@ struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat,
|
||||||
|
|
||||||
keyboard->key_repeat_source = wl_event_loop_add_timer(server.wl_event_loop,
|
keyboard->key_repeat_source = wl_event_loop_add_timer(server.wl_event_loop,
|
||||||
handle_keyboard_repeat, keyboard);
|
handle_keyboard_repeat, keyboard);
|
||||||
keyboard->key_repeat_initial_delay = 660;
|
|
||||||
keyboard->key_repeat_step_delay = 40;
|
|
||||||
|
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue