backend/wayland: handle wl_registry.global_remove for wl_seat

Destroy the struct wlr_wl_seat when the global is removed.
Simon Ser 2 years ago committed by Alexander Orzechowski
parent 2b5eb0733e
commit cfa7696d7b

@ -354,7 +354,7 @@ static void registry_global(void *data, struct wl_registry *registry,
} }
struct wl_seat *wl_seat = wl_registry_bind(registry, name, struct wl_seat *wl_seat = wl_registry_bind(registry, name,
&wl_seat_interface, target_version); &wl_seat_interface, target_version);
if (!create_wl_seat(wl_seat, wl)) { if (!create_wl_seat(wl_seat, wl, name)) {
wl_seat_destroy(wl_seat); wl_seat_destroy(wl_seat);
} }
} else if (strcmp(iface, xdg_wm_base_interface.name) == 0) { } else if (strcmp(iface, xdg_wm_base_interface.name) == 0) {
@ -398,7 +398,15 @@ static void registry_global(void *data, struct wl_registry *registry,
static void registry_global_remove(void *data, struct wl_registry *registry, static void registry_global_remove(void *data, struct wl_registry *registry,
uint32_t name) { uint32_t name) {
// TODO struct wlr_wl_backend *wl = data;
struct wlr_wl_seat *seat;
wl_list_for_each(seat, &wl->seats, link) {
if (seat->global_name == name) {
destroy_wl_seat(seat);
break;
}
}
} }
static const struct wl_registry_listener registry_listener = { static const struct wl_registry_listener registry_listener = {

@ -233,7 +233,8 @@ void init_seat_touch(struct wlr_wl_seat *seat) {
static const struct wl_seat_listener seat_listener; static const struct wl_seat_listener seat_listener;
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,
uint32_t global_name) {
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");
@ -241,6 +242,7 @@ 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;
seat->global_name = global_name;
wl_list_insert(&wl->seats, &seat->link); 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;

@ -105,6 +105,7 @@ struct wlr_wl_pointer {
struct wlr_wl_seat { struct wlr_wl_seat {
char *name; char *name;
struct wl_seat *wl_seat; struct wl_seat *wl_seat;
uint32_t global_name;
struct wlr_wl_backend *backend; struct wlr_wl_backend *backend;
@ -148,7 +149,8 @@ void init_seat_touch(struct wlr_wl_seat *seat);
void init_seat_tablet(struct wlr_wl_seat *seat); void init_seat_tablet(struct wlr_wl_seat *seat);
void finish_seat_tablet(struct wlr_wl_seat *seat); void finish_seat_tablet(struct wlr_wl_seat *seat);
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,
uint32_t global_name);
void destroy_wl_seat(struct wlr_wl_seat *seat); void destroy_wl_seat(struct wlr_wl_seat *seat);
void destroy_wl_buffer(struct wlr_wl_buffer *buffer); void destroy_wl_buffer(struct wlr_wl_buffer *buffer);

Loading…
Cancel
Save