backend/wayland: Add registering multiple seats

This commit is contained in:
Mykola Orliuk 2020-10-03 23:06:10 +02:00 committed by Simon Ser
parent 85b0872650
commit 70ffda3ea3
4 changed files with 25 additions and 25 deletions

View File

@ -157,8 +157,8 @@ static bool backend_start(struct wlr_backend *backend) {
wl->started = true; wl->started = true;
struct wlr_wl_seat *seat = wl->seat; struct wlr_wl_seat *seat;
if (seat != NULL) { wl_list_for_each(seat, &wl->seats, link) {
if (seat->keyboard) { if (seat->keyboard) {
create_wl_keyboard(seat); create_wl_keyboard(seat);
} }
@ -262,6 +262,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
wl->local_display = display; wl->local_display = display;
wl_list_init(&wl->devices); wl_list_init(&wl->devices);
wl_list_init(&wl->outputs); wl_list_init(&wl->outputs);
wl_list_init(&wl->seats);
wl->remote_display = wl_display_connect(remote); wl->remote_display = wl_display_connect(remote);
if (!wl->remote_display) { if (!wl->remote_display) {

View File

@ -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); wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output);
struct wlr_wl_seat *seat = backend->seat; struct wlr_wl_seat *seat;
if (seat != NULL) { wl_list_for_each(seat, &backend->seats, link) {
if (seat->pointer) { if (seat->pointer) {
create_wl_pointer(seat, output); create_wl_pointer(seat, output);
} }

View File

@ -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) { 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)); struct wlr_wl_seat *seat = calloc(1, sizeof(struct wlr_wl_seat));
if (!seat) { if (!seat) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); 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->wl_seat = wl_seat;
seat->backend = wl; seat->backend = wl;
wl->seat = seat; wl_list_insert(&wl->seats, &seat->link);
wl_seat_add_listener(wl_seat, &seat_listener, seat); wl_seat_add_listener(wl_seat, &seat_listener, seat);
return true; return true;
} }
void destroy_wl_seats(struct wlr_wl_backend *wl) { void destroy_wl_seats(struct wlr_wl_backend *wl) {
struct wlr_wl_seat *seat = wl->seat; struct wlr_wl_seat *seat, *tmp_seat;
if (!seat) { wl_list_for_each_safe(seat, tmp_seat, &wl->seats, link) {
return; if (seat->touch) {
} wl_touch_destroy(seat->touch);
}
if (seat->touch) { if (seat->pointer) {
wl_touch_destroy(seat->touch); wl_pointer_destroy(seat->pointer);
} }
if (seat->pointer) { if (seat->keyboard && !wl->started) {
wl_pointer_destroy(seat->pointer); // early termination will not be handled by input_device_destroy
} wl_keyboard_destroy(seat->keyboard);
if (seat->keyboard && !wl->started) { }
// early termination will not be handled by input_device_destroy free(seat->name);
wl_keyboard_destroy(seat->keyboard); assert(seat->wl_seat);
}
free(seat->name);
if (seat->wl_seat) {
wl_seat_destroy(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) { static struct wlr_wl_seat *input_device_get_seat(struct wlr_input_device *wlr_dev) {

View File

@ -39,7 +39,7 @@ struct wlr_wl_backend {
struct wp_presentation *presentation; struct wp_presentation *presentation;
struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1; struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1;
struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_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 wlr_wl_pointer *current_pointer;
struct zwp_tablet_manager_v2 *tablet_manager; struct zwp_tablet_manager_v2 *tablet_manager;
struct wlr_drm_format_set linux_dmabuf_v1_formats; struct wlr_drm_format_set linux_dmabuf_v1_formats;
@ -109,6 +109,7 @@ struct wlr_wl_pointer {
struct wlr_wl_seat { struct wlr_wl_seat {
struct wl_seat *wl_seat; struct wl_seat *wl_seat;
struct wl_list link; // wlr_wl_backend.seats
char *name; char *name;
struct wl_touch *touch; struct wl_touch *touch;
struct wl_pointer *pointer; struct wl_pointer *pointer;