dont copy seat config on the seat

This commit is contained in:
Tony Crisci 2018-04-02 10:37:31 -04:00
parent 0828c77251
commit 53bb7ea996
3 changed files with 35 additions and 22 deletions

View file

@ -23,7 +23,6 @@ struct sway_seat_container {
struct sway_seat {
struct wlr_seat *wlr_seat;
struct seat_config *config;
struct sway_cursor *cursor;
struct sway_input_manager *input;
@ -76,6 +75,8 @@ struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
enum sway_container_type type);
void seat_set_config(struct sway_seat *seat, struct seat_config *seat_config);
void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
struct seat_config *seat_get_config(struct sway_seat *seat);
#endif

View file

@ -83,7 +83,8 @@ static struct sway_input_device *input_sway_device_from_wlr(
static bool input_has_seat_configuration(struct sway_input_manager *input) {
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &input->seats, link) {
if (seat->config) {
struct seat_config *seat_config = seat_get_config(seat);
if (seat_config) {
return true;
}
}
@ -225,11 +226,13 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
return;
}
struct seat_config *seat_config = seat_get_config(seat);
bool added = false;
wl_list_for_each(seat, &input->seats, link) {
bool has_attachment = seat->config &&
(seat_config_get_attachment(seat->config, input_device->identifier) ||
seat_config_get_attachment(seat->config, "*"));
bool has_attachment = config &&
(seat_config_get_attachment(seat_config, input_device->identifier) ||
seat_config_get_attachment(seat_config, "*"));
if (has_attachment) {
seat_add_device(seat, input_device);
@ -239,7 +242,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
if (!added) {
wl_list_for_each(seat, &input->seats, link) {
if (seat->config && seat->config->fallback == 1) {
if (seat_config && seat_config->fallback == 1) {
seat_add_device(seat, input_device);
added = true;
}
@ -326,7 +329,7 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
return;
}
seat_set_config(seat, seat_config);
seat_apply_config(seat, seat_config);
// for every device, try to add it to a seat and if no seat has it
// attached, add it to the fallback seats.
@ -335,11 +338,12 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
list_t *seat_list = create_list();
struct sway_seat *seat = NULL;
wl_list_for_each(seat, &input->seats, link) {
if (!seat->config) {
struct seat_config *seat_config = seat_get_config(seat);
if (!seat_config) {
continue;
}
if (seat_config_get_attachment(seat->config, "*") ||
seat_config_get_attachment(seat->config,
if (seat_config_get_attachment(seat_config, "*") ||
seat_config_get_attachment(seat_config,
input_device->identifier)) {
list_add(seat_list, seat);
}
@ -362,7 +366,8 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
}
} else {
wl_list_for_each(seat, &input->seats, link) {
if (seat->config && seat->config->fallback == 1) {
struct seat_config *seat_config = seat_get_config(seat);
if (seat_config && seat_config->fallback == 1) {
seat_add_device(seat, input_device);
} else {
seat_remove_device(seat, input_device);

View file

@ -199,9 +199,11 @@ void seat_configure_device(struct sway_seat *seat,
return;
}
if (seat->config) {
struct seat_config *seat_config = seat_get_config(seat);
if (seat_config) {
seat_device->attachment_config =
seat_config_get_attachment(seat->config, input_device->identifier);
seat_config_get_attachment(seat_config, input_device->identifier);
}
switch (input_device->wlr_device->type) {
@ -415,12 +417,8 @@ struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
return container_parent(focus, type);
}
void seat_set_config(struct sway_seat *seat,
void seat_apply_config(struct sway_seat *seat,
struct seat_config *seat_config) {
// clear configs
free_seat_config(seat->config);
seat->config = NULL;
struct sway_seat_device *seat_device = NULL;
wl_list_for_each(seat_device, &seat->devices, link) {
seat_device->attachment_config = NULL;
@ -430,10 +428,19 @@ void seat_set_config(struct sway_seat *seat,
return;
}
// add configs
seat->config = copy_seat_config(seat_config);
wl_list_for_each(seat_device, &seat->devices, link) {
seat_configure_device(seat, seat_device->input_device);
}
}
struct seat_config *seat_get_config(struct sway_seat *seat) {
struct seat_config *seat_config = NULL;
for (int i = 0; i < config->seat_configs->length; ++i ) {
seat_config = config->seat_configs->items[i];
if (strcmp(seat->wlr_seat->name, seat_config->name) == 0) {
return seat_config;
}
}
return NULL;
}