diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index bd4d6eb6..314d45cd 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -157,8 +157,8 @@ static bool backend_start(struct wlr_backend *backend) { wl->started = true; - struct wlr_wl_seat *seat = wl->seat; - if (seat != NULL) { + struct wlr_wl_seat *seat; + wl_list_for_each(seat, &wl->seats, link) { if (seat->keyboard) { create_wl_keyboard(seat); } @@ -262,6 +262,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, wl->local_display = display; wl_list_init(&wl->devices); wl_list_init(&wl->outputs); + wl_list_init(&wl->seats); wl->remote_display = wl_display_connect(remote); if (!wl->remote_display) { diff --git a/backend/wayland/output.c b/backend/wayland/output.c index c8149149..3899f7f4 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -586,8 +586,8 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) { wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output); - struct wlr_wl_seat *seat = backend->seat; - if (seat != NULL) { + struct wlr_wl_seat *seat; + wl_list_for_each(seat, &backend->seats, link) { if (seat->pointer) { create_wl_pointer(seat, output); } diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c index e038bb52..ebb9c84c 100644 --- a/backend/wayland/seat.c +++ b/backend/wayland/seat.c @@ -373,7 +373,6 @@ static struct wlr_wl_input_device *get_wl_input_device_from_input_device( } bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl) { - assert(!wl->seat); // only one seat supported at the moment struct wlr_wl_seat *seat = calloc(1, sizeof(struct wlr_wl_seat)); if (!seat) { wlr_log_errno(WLR_ERROR, "Allocation failed"); @@ -381,32 +380,31 @@ bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl) { } seat->wl_seat = wl_seat; seat->backend = wl; - wl->seat = seat; + wl_list_insert(&wl->seats, &seat->link); wl_seat_add_listener(wl_seat, &seat_listener, seat); return true; } void destroy_wl_seats(struct wlr_wl_backend *wl) { - struct wlr_wl_seat *seat = wl->seat; - if (!seat) { - return; - } - - if (seat->touch) { - wl_touch_destroy(seat->touch); - } - if (seat->pointer) { - wl_pointer_destroy(seat->pointer); - } - if (seat->keyboard && !wl->started) { - // early termination will not be handled by input_device_destroy - wl_keyboard_destroy(seat->keyboard); - } - free(seat->name); - if (seat->wl_seat) { + struct wlr_wl_seat *seat, *tmp_seat; + wl_list_for_each_safe(seat, tmp_seat, &wl->seats, link) { + if (seat->touch) { + wl_touch_destroy(seat->touch); + } + if (seat->pointer) { + wl_pointer_destroy(seat->pointer); + } + if (seat->keyboard && !wl->started) { + // early termination will not be handled by input_device_destroy + wl_keyboard_destroy(seat->keyboard); + } + free(seat->name); + assert(seat->wl_seat); wl_seat_destroy(seat->wl_seat); + + wl_list_remove(&seat->link); + free(seat); } - free(seat); } static struct wlr_wl_seat *input_device_get_seat(struct wlr_input_device *wlr_dev) { diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 65fe6bbc..20292625 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -39,7 +39,7 @@ struct wlr_wl_backend { struct wp_presentation *presentation; struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1; struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1; - struct wlr_wl_seat *seat; + struct wl_list seats; // wlr_wl_seat.link struct wlr_wl_pointer *current_pointer; struct zwp_tablet_manager_v2 *tablet_manager; struct wlr_drm_format_set linux_dmabuf_v1_formats; @@ -109,6 +109,7 @@ struct wlr_wl_pointer { struct wlr_wl_seat { struct wl_seat *wl_seat; + struct wl_list link; // wlr_wl_backend.seats char *name; struct wl_touch *touch; struct wl_pointer *pointer;