remove empty seats

This commit is contained in:
madblobfish 2018-11-01 09:28:02 +01:00
parent afd66d63cc
commit 6e85e7ec89
5 changed files with 19 additions and 0 deletions

View file

@ -53,6 +53,8 @@ struct sway_seat *input_manager_get_seat(const char *seat_name, bool create);
*/ */
void input_manager_verify_fallback_seat(void); void input_manager_verify_fallback_seat(void);
void input_manager_seat_consider_destroy(const char *seat_name);
/** /**
* Gets the last seat the user interacted with * Gets the last seat the user interacted with
*/ */

View file

@ -94,6 +94,8 @@ struct sway_seat *seat_create(const char *seat_name);
void seat_destroy(struct sway_seat *seat); void seat_destroy(struct sway_seat *seat);
void seat_consider_destroy(struct sway_seat *seat);
void seat_add_device(struct sway_seat *seat, void seat_add_device(struct sway_seat *seat,
struct sway_input_device *device); struct sway_input_device *device);

View file

@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/input/input-manager.h"
struct cmd_results *seat_cmd_detach(int argc, char **argv) { struct cmd_results *seat_cmd_detach(int argc, char **argv) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
@ -23,5 +24,8 @@ struct cmd_results *seat_cmd_detach(int argc, char **argv) {
if (!config->validating) { if (!config->validating) {
input_manager_apply_seat_config(new_seat_config(current_seat_config->name)); input_manager_apply_seat_config(new_seat_config(current_seat_config->name));
} }
input_manager_seat_consider_destroy(current_seat_config->name);
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }

View file

@ -729,6 +729,11 @@ void input_manager_apply_seat_config(struct seat_config *seat_config) {
} }
} }
void input_manager_seat_consider_destroy(const char *seat_name) {
struct sway_seat *seat = input_manager_get_seat(seat_name, false);
seat_consider_destroy(seat);
}
void input_manager_configure_xcursor(void) { void input_manager_configure_xcursor(void) {
struct sway_seat *seat = NULL; struct sway_seat *seat = NULL;
wl_list_for_each(seat, &server.input->seats, link) { wl_list_for_each(seat, &server.input->seats, link) {

View file

@ -59,6 +59,12 @@ static void seat_node_destroy(struct sway_seat_node *seat_node) {
free(seat_node); free(seat_node);
} }
void seat_consider_destroy(struct sway_seat *seat) {
if (wl_list_empty(&seat->devices)) {
seat_destroy(seat);
}
}
/** /**
* Activate all views within this container recursively. * Activate all views within this container recursively.
*/ */