mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-17 22:05:22 -05:00
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:
parent
bf62519d83
commit
5677df629e
1 changed files with 12 additions and 6 deletions
18
wayland.c
18
wayland.c
|
|
@ -176,13 +176,25 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
|
||||
if (caps & WL_SEAT_CAPABILITY_POINTER) {
|
||||
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);
|
||||
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
|
||||
}
|
||||
} else {
|
||||
if (seat->wl_pointer != NULL) {
|
||||
wl_pointer_release(seat->wl_pointer);
|
||||
wl_surface_destroy(seat->pointer.surface);
|
||||
|
||||
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
|
||||
primary_selection_device = NULL;
|
||||
|
||||
struct wl_surface *pointer_surf
|
||||
= wl_compositor_create_surface(wayl->compositor);
|
||||
|
||||
tll_push_back(wayl->seats, ((struct seat){
|
||||
.wayl = wayl,
|
||||
.wl_seat = wl_seat,
|
||||
|
|
@ -715,9 +724,6 @@ handle_global(void *data, struct wl_registry *registry,
|
|||
.fd = repeat_fd,
|
||||
},
|
||||
},
|
||||
.pointer = {
|
||||
.surface = pointer_surf,
|
||||
},
|
||||
.data_device = data_device,
|
||||
.primary_selection_device = primary_selection_device,
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue