diff options
-rw-r--r-- | include/sway/input/input-manager.h | 2 | ||||
-rw-r--r-- | sway/commands/seat/cursor.c | 5 | ||||
-rw-r--r-- | sway/config.c | 11 | ||||
-rw-r--r-- | sway/input/cursor.c | 6 | ||||
-rw-r--r-- | sway/input/input-manager.c | 9 |
5 files changed, 23 insertions, 10 deletions
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 8e8bf1f2..e166a237 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -45,7 +45,7 @@ void input_manager_apply_seat_config(struct seat_config *seat_config); 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, bool create); /** * If none of the seat configs have a fallback setting (either true or false), diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 4f805b22..0c7609ea 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c @@ -61,9 +61,10 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { } if (strcmp(sc->name, "*") != 0) { - struct sway_seat *seat = input_manager_get_seat(sc->name); + struct sway_seat *seat = input_manager_get_seat(sc->name, false); if (!seat) { - return cmd_results_new(CMD_FAILURE, "Failed to get seat"); + return cmd_results_new(CMD_FAILURE, + "Seat %s does not exist", sc->name); } error = handle_command(seat->cursor, argc, argv); } else { diff --git a/sway/config.c b/sway/config.c index 7cb27d95..ee1c42df 100644 --- a/sway/config.c +++ b/sway/config.c @@ -141,11 +141,18 @@ static void destroy_removed_seats(struct sway_config *old_config, int i; for (i = 0; i < old_config->seat_configs->length; i++) { seat_config = old_config->seat_configs->items[i]; + // Skip the wildcard seat config, it won't have a matching real seat. + if (strcmp(seat_config->name, "*") == 0) { + continue; + } + /* Also destroy seats that aren't present in new config */ if (new_config && list_seq_find(new_config->seat_configs, seat_name_cmp, seat_config->name) < 0) { - seat = input_manager_get_seat(seat_config->name); - seat_destroy(seat); + seat = input_manager_get_seat(seat_config->name, false); + if (seat) { + seat_destroy(seat); + } } } } diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 250100cc..1bf548db 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1459,7 +1459,11 @@ void handle_pointer_constraint(struct wl_listener *listener, void *data) { void sway_cursor_constrain(struct sway_cursor *cursor, struct wlr_pointer_constraint_v1 *constraint) { struct seat_config *config = seat_get_config(cursor->seat); - if (config->allow_constrain == CONSTRAIN_DISABLE) { + if (!config) { + config = seat_get_config_by_name("*"); + } + + if (!config || config->allow_constrain == CONSTRAIN_DISABLE) { return; } diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 8d263e06..f99fc395 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -31,10 +31,10 @@ struct sway_seat *input_manager_current_seat(void) { } struct sway_seat *input_manager_get_default_seat(void) { - return input_manager_get_seat(DEFAULT_SEAT); + return input_manager_get_seat(DEFAULT_SEAT, true); } -struct sway_seat *input_manager_get_seat(const char *seat_name) { +struct sway_seat *input_manager_get_seat(const char *seat_name, bool create) { struct sway_seat *seat = NULL; wl_list_for_each(seat, &server.input->seats, link) { if (strcmp(seat->wlr_seat->name, seat_name) == 0) { @@ -42,7 +42,7 @@ struct sway_seat *input_manager_get_seat(const char *seat_name) { } } - return seat_create(seat_name); + return create ? seat_create(seat_name) : NULL; } char *input_device_get_identifier(struct wlr_input_device *device) { @@ -674,7 +674,8 @@ void input_manager_apply_seat_config(struct seat_config *seat_config) { seat_apply_config(seat, sc); } } else { - struct sway_seat *seat = input_manager_get_seat(seat_config->name); + struct sway_seat *seat = + input_manager_get_seat(seat_config->name, true); if (!seat) { return; } |