From 82423991a8512ab97fbc41d1e190e709c58bc346 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 8 Oct 2018 19:28:53 +1000 Subject: Reload config using idle event This patch makes it so when you run reload, the actual reloading is deferred to the next time the event loop becomes idle. This avoids several use-after-frees and removes the workarounds we have to avoid them. When you run reload, we validate the config before creating the idle event. This is so the reload command will still return an error if there are validation errors. To allow this, load_main_config has been adjusted so it doesn't apply the config if validating is true rather than applying it unconditionally. This also fixes a memory leak in the reload command where if the config failed to load, the bar_ids list would not be freed. --- sway/input/keyboard.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sway/input/keyboard.c') diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 5fc8a806..0e14c036 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -278,9 +278,7 @@ 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; - } + next_repeat_binding = binding_pressed; seat_execute_command(seat, binding_pressed); handled = true; } -- cgit v1.2.3 From 88a5e26c6eeb28cf934401d377654236fdf8cdfd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 8 Oct 2018 20:40:47 +1000 Subject: Remove unneeded variable --- sway/input/keyboard.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'sway/input/keyboard.c') diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 0e14c036..fb1fe7b5 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -264,29 +264,27 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { } // Identify and execute active pressed binding - struct sway_binding *next_repeat_binding = NULL; + struct sway_binding *binding = NULL; if (event->state == WLR_KEY_PRESSED) { - struct sway_binding *binding_pressed = NULL; get_active_binding(&keyboard->state_keycodes, - config->current_mode->keycode_bindings, &binding_pressed, + config->current_mode->keycode_bindings, &binding, code_modifiers, false, input_inhibited); get_active_binding(&keyboard->state_keysyms_translated, - config->current_mode->keysym_bindings, &binding_pressed, + config->current_mode->keysym_bindings, &binding, translated_modifiers, false, input_inhibited); get_active_binding(&keyboard->state_keysyms_raw, - config->current_mode->keysym_bindings, &binding_pressed, + config->current_mode->keysym_bindings, &binding, raw_modifiers, false, input_inhibited); - if (binding_pressed) { - next_repeat_binding = binding_pressed; - seat_execute_command(seat, binding_pressed); + if (binding) { + seat_execute_command(seat, binding); 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 (binding && wlr_device->keyboard->repeat_info.delay > 0) { + keyboard->repeat_binding = 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"); -- cgit v1.2.3