sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit 09bb71f6507d86d98b5b9825f28b91ddd4b9a09b
parent 3e8f548d1d0acb3aba384842615e6528b3027283
Author: Brian Ashworth <bosrsf04@gmail.com>
Date:   Sat, 29 Dec 2018 21:50:03 -0500

Verify seat fallback settings on reload

This fixes an issue where on reload, all input devices that were added
via an implicit fallback to the default seat would be removed from the
default seat and applications would crash due to the seat having no
capabilities.

On reload, there is a query for a seat config with the fallback setting
set (it can either be true or false). If no such seat config exists, the
default seat is created (if needed) and has the implicit fallback true
applied to its seat config. This is the same procedure that occurs when
a new input is detected.

Diffstat:
Minclude/sway/input/input-manager.h | 6++++++
Msway/config.c | 1+
Msway/input/input-manager.c | 21+++++++++++++--------
3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h @@ -44,6 +44,12 @@ struct sway_seat *input_manager_get_default_seat(void); struct sway_seat *input_manager_get_seat(const char *seat_name); /** + * If none of the seat configs have a fallback setting (either true or false), + * create the default seat (if needed) and set it as the fallback + */ +void input_manager_verify_fallback_seat(void); + +/** * Gets the last seat the user interacted with */ struct sway_seat *input_manager_current_seat(void); diff --git a/sway/config.c b/sway/config.c @@ -465,6 +465,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) { if (config->swaynag_config_errors.pid > 0) { swaynag_show(&config->swaynag_config_errors); } + input_manager_verify_fallback_seat(); } if (old_config) { diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c @@ -95,6 +95,17 @@ static bool input_has_seat_fallback_configuration(void) { return false; } +void input_manager_verify_fallback_seat(void) { + struct sway_seat *seat = NULL; + if (!input_has_seat_fallback_configuration()) { + wlr_log(WLR_DEBUG, "no fallback seat config - creating default"); + seat = input_manager_get_default_seat(); + struct seat_config *sc = new_seat_config(seat->wlr_seat->name); + sc->fallback = true; + store_seat_config(sc); + } +} + static void input_manager_libinput_config_keyboard( struct sway_input_device *input_device) { struct wlr_input_device *wlr_device = input_device->wlr_device; @@ -296,16 +307,10 @@ static void handle_new_input(struct wl_listener *listener, void *data) { wl_signal_add(&device->events.destroy, &input_device->device_destroy); input_device->device_destroy.notify = handle_device_destroy; - struct sway_seat *seat = NULL; - if (!input_has_seat_fallback_configuration()) { - wlr_log(WLR_DEBUG, "no seat config - creating default seat config"); - seat = input_manager_get_default_seat(); - struct seat_config *sc = new_seat_config(seat->wlr_seat->name); - sc->fallback = true; - store_seat_config(sc); - } + input_manager_verify_fallback_seat(); bool added = false; + struct sway_seat *seat = NULL; wl_list_for_each(seat, &input->seats, link) { struct seat_config *seat_config = seat_get_config(seat); bool has_attachment = seat_config &&