diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 5fc8a8062..fa613c9b3 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -263,8 +263,10 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { keyboard->held_binding = binding_released; } + // Clear keyboard repeat + keyboard->repeat_binding = NULL; + // Identify and execute active pressed binding - struct sway_binding *next_repeat_binding = NULL; if (event->state == WLR_KEY_PRESSED) { struct sway_binding *binding_pressed = NULL; get_active_binding(&keyboard->state_keycodes, @@ -278,28 +280,21 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { raw_modifiers, false, input_inhibited); if (binding_pressed) { - if ((binding_pressed->flags & BINDING_RELOAD) == 0) { - next_repeat_binding = binding_pressed; + // Set up keyboard repeat for a pressed binding, except for reloads + if ((binding_pressed->flags & BINDING_RELOAD) == 0 && + wlr_device->keyboard->repeat_info.delay > 0) { + keyboard->repeat_binding = binding_pressed; + if (wl_event_source_timer_update(keyboard->key_repeat_source, + wlr_device->keyboard->repeat_info.delay) < 0) { + wlr_log(WLR_DEBUG, "failed to set key repeat timer"); + } } + seat_execute_command(seat, 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, - wlr_device->keyboard->repeat_info.delay) < 0) { - 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) { - wlr_log(WLR_DEBUG, "failed to disarm key repeat timer"); - } - } - // Compositor bindings if (!handled && event->state == WLR_KEY_PRESSED) { handled = keyboard_execute_compositor_binding(