aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-06-26 15:31:14 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-06-29 13:38:23 +0000
commite5989d81b931afb31ac0ac3df9269841adef2d98 (patch)
tree747ee3b4dc1ee1a11331e3c33c0807288ad63537
parentwayland: refactor: add a buffer argument to wayl_*_scale() functions (diff)
wayland: instantiate+destroy viewport for pointer surface
-rw-r--r--wayland.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/wayland.c b/wayland.c
index 43f85066..6dea027d 100644
--- a/wayland.c
+++ b/wayland.c
@@ -293,13 +293,27 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
if (caps & WL_SEAT_CAPABILITY_POINTER) {
if (seat->wl_pointer == NULL) {
xassert(seat->pointer.surface.surf == NULL);
- seat->pointer.surface.surf = wl_compositor_create_surface(seat->wayl->compositor);
+ seat->pointer.surface.surf =
+ wl_compositor_create_surface(seat->wayl->compositor);
if (seat->pointer.surface.surf == NULL) {
LOG_ERR("%s: failed to create pointer surface", seat->name);
return;
}
+#if defined(HAVE_FRACTIONAL_SCALE)
+ xassert(seat->pointer.surface.viewport == NULL);
+ seat->pointer.surface.viewport = wp_viewporter_get_viewport(
+ seat->wayl->viewporter, seat->pointer.surface.surf);
+
+ if (seat->pointer.surface.viewport == NULL) {
+ LOG_ERR("%s: failed to create pointer viewport", seat->name);
+ wl_surface_destroy(seat->pointer.surface.surf);
+ seat->pointer.surface.surf = NULL;
+ return;
+ }
+#endif
+
seat->wl_pointer = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
}
@@ -308,6 +322,11 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
wl_pointer_release(seat->wl_pointer);
wl_surface_destroy(seat->pointer.surface.surf);
+#if defined(HAVE_FRACTIONAL_SCALE)
+ wp_viewport_destroy(seat->pointer.surface.viewport);
+ seat->pointer.surface.viewport = NULL;
+#endif
+
if (seat->pointer.theme != NULL)
wl_cursor_theme_destroy(seat->pointer.theme);