aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-10 17:24:33 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-10 17:24:33 +0000
commit5677df629e4323c8e8ca24d11dd63725934a4c98 (patch)
tree7b234ebc2a6690eccb293ffdb44c237135e4918d
parentwayland: read XCURSOR_{THEME,SIZE} in reload_xcursor theme (diff)
wayland: seat: instantiate pointer surface in capabilities event
This way we only instantiate the surface for seats that actually have a pointer.
-rw-r--r--wayland.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/wayland.c b/wayland.c
index 2ba385fa..9a6df83b 100644
--- a/wayland.c
+++ b/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,
}));