bar/wayland: don't destroy pointer unnecessarily

We only need to create/destroy the pointer when the POINTER capability
changes.
This commit is contained in:
Daniel Eklöf 2020-04-28 18:57:32 +02:00
parent c3b3d6a637
commit c707b00a2a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -235,14 +235,16 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
{ {
struct wayland_backend *backend = data; struct wayland_backend *backend = data;
if (backend->pointer.pointer != NULL) { if (caps & WL_SEAT_CAPABILITY_POINTER) {
wl_pointer_release(backend->pointer.pointer); if (backend->pointer.pointer == NULL) {
backend->pointer.pointer = NULL; backend->pointer.pointer = wl_seat_get_pointer(wl_seat);
} wl_pointer_add_listener(backend->pointer.pointer, &pointer_listener, backend);
}
if ((caps & WL_SEAT_CAPABILITY_POINTER)) { } else {
backend->pointer.pointer = wl_seat_get_pointer(wl_seat); if (backend->pointer.pointer != NULL) {
wl_pointer_add_listener(backend->pointer.pointer, &pointer_listener, backend); wl_pointer_release(backend->pointer.pointer);
backend->pointer.pointer = NULL;
}
} }
} }