mirror of
https://github.com/swaywm/sway.git
synced 2026-04-29 06:46:22 -04:00
Fix crash on reload when keyboard is configured
If the keyboard was configured, it would be destroyed when reloading. This meant that setting the repeat binding on the destroyed keyboard would cause a segmentation fault. This commit sets the repeat binding before running the command.
This commit is contained in:
parent
06fade1c8b
commit
e6a6bdbac1
1 changed files with 12 additions and 17 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue