This commit is contained in:
Ian Fan 2018-10-07 21:48:10 +00:00 committed by GitHub
commit 560cbfe223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -263,8 +263,10 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
keyboard->held_binding = binding_released; keyboard->held_binding = binding_released;
} }
// Clear keyboard repeat
keyboard->repeat_binding = NULL;
// Identify and execute active pressed binding // Identify and execute active pressed binding
struct sway_binding *next_repeat_binding = NULL;
if (event->state == WLR_KEY_PRESSED) { if (event->state == WLR_KEY_PRESSED) {
struct sway_binding *binding_pressed = NULL; struct sway_binding *binding_pressed = NULL;
get_active_binding(&keyboard->state_keycodes, get_active_binding(&keyboard->state_keycodes,
@ -278,25 +280,18 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
raw_modifiers, false, input_inhibited); raw_modifiers, false, input_inhibited);
if (binding_pressed) { if (binding_pressed) {
if ((binding_pressed->flags & BINDING_RELOAD) == 0) { // Set up keyboard repeat for a pressed binding, except for reloads
next_repeat_binding = binding_pressed; if ((binding_pressed->flags & BINDING_RELOAD) == 0 &&
} wlr_device->keyboard->repeat_info.delay > 0) {
seat_execute_command(seat, binding_pressed); keyboard->repeat_binding = binding_pressed;
handled = true;
}
}
// Set up (or clear) keyboard repeat for a pressed binding
if (next_repeat_binding && wlr_device->keyboard->repeat_info.delay > 0) {
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,
wlr_device->keyboard->repeat_info.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) { }
keyboard->repeat_binding = NULL;
if (wl_event_source_timer_update(keyboard->key_repeat_source, 0) < 0) { seat_execute_command(seat, binding_pressed);
wlr_log(WLR_DEBUG, "failed to disarm key repeat timer"); handled = true;
} }
} }