wayland: seat: instantiate pointer surface in capabilities event

This way we only instantiate the surface for seats that actually have
a pointer.
This commit is contained in:
Daniel Eklöf 2020-07-10 19:24:33 +02:00
parent bf62519d83
commit 5677df629e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -176,13 +176,25 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
if (caps & WL_SEAT_CAPABILITY_POINTER) { if (caps & WL_SEAT_CAPABILITY_POINTER) {
if (seat->wl_pointer == NULL) { if (seat->wl_pointer == NULL) {
assert(seat->pointer.surface == NULL);
seat->pointer.surface = wl_compositor_create_surface(seat->wayl->compositor);
if (seat->pointer.surface == NULL) {
LOG_ERR("%s: failed to create pointer surface", seat->name);
return;
}
seat->wl_pointer = wl_seat_get_pointer(wl_seat); seat->wl_pointer = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat); wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
} }
} else { } else {
if (seat->wl_pointer != NULL) { if (seat->wl_pointer != NULL) {
wl_pointer_release(seat->wl_pointer); wl_pointer_release(seat->wl_pointer);
wl_surface_destroy(seat->pointer.surface);
seat->wl_pointer = NULL; seat->wl_pointer = NULL;
seat->pointer.surface = NULL;
seat->pointer.cursor = NULL;
} }
} }
} }
@ -703,9 +715,6 @@ handle_global(void *data, struct wl_registry *registry,
} else } else
primary_selection_device = NULL; primary_selection_device = NULL;
struct wl_surface *pointer_surf
= wl_compositor_create_surface(wayl->compositor);
tll_push_back(wayl->seats, ((struct seat){ tll_push_back(wayl->seats, ((struct seat){
.wayl = wayl, .wayl = wayl,
.wl_seat = wl_seat, .wl_seat = wl_seat,
@ -715,9 +724,6 @@ handle_global(void *data, struct wl_registry *registry,
.fd = repeat_fd, .fd = repeat_fd,
}, },
}, },
.pointer = {
.surface = pointer_surf,
},
.data_device = data_device, .data_device = data_device,
.primary_selection_device = primary_selection_device, .primary_selection_device = primary_selection_device,
})); }));