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.
This commit is contained in:
Brian Ashworth 2018-12-29 21:50:03 -05:00 committed by emersion
parent 3e8f548d1d
commit 09bb71f650
3 changed files with 20 additions and 8 deletions

View file

@ -43,6 +43,12 @@ struct sway_seat *input_manager_get_default_seat(void);
struct sway_seat *input_manager_get_seat(const char *seat_name); 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 * Gets the last seat the user interacted with
*/ */

View file

@ -465,6 +465,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
if (config->swaynag_config_errors.pid > 0) { if (config->swaynag_config_errors.pid > 0) {
swaynag_show(&config->swaynag_config_errors); swaynag_show(&config->swaynag_config_errors);
} }
input_manager_verify_fallback_seat();
} }
if (old_config) { if (old_config) {

View file

@ -95,6 +95,17 @@ static bool input_has_seat_fallback_configuration(void) {
return false; 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( static void input_manager_libinput_config_keyboard(
struct sway_input_device *input_device) { struct sway_input_device *input_device) {
struct wlr_input_device *wlr_device = input_device->wlr_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); wl_signal_add(&device->events.destroy, &input_device->device_destroy);
input_device->device_destroy.notify = handle_device_destroy; input_device->device_destroy.notify = handle_device_destroy;
struct sway_seat *seat = NULL; input_manager_verify_fallback_seat();
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);
}
bool added = false; bool added = false;
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &input->seats, link) { wl_list_for_each(seat, &input->seats, link) {
struct seat_config *seat_config = seat_get_config(seat); struct seat_config *seat_config = seat_get_config(seat);
bool has_attachment = seat_config && bool has_attachment = seat_config &&