aboutsummaryrefslogtreecommitdiff
path: root/wayland.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-07-28 13:32:42 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-07-28 13:42:28 +0000
commit9d75c551465fa3dbb3cd20ae87d6de294fcebce1 (patch)
treec6223cf887be2fd2810ebb1b3d134fa9a6ca1ac3 /wayland.c
parentmeson: add -Dterminfo-base-name option (diff)
wayland: don't try to use a non-existing viewporter interface
When instantiating the viewport for a pointer surface, we didn't first check if the compositor implements the viewporter interface. This triggered a crash when a) foot was compiled with fractional scaling, and b) the compositor did not implement the viewporter interface. Closes #1444
Diffstat (limited to 'wayland.c')
-rw-r--r--wayland.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/wayland.c b/wayland.c
index acf078aa..9a6609f4 100644
--- a/wayland.c
+++ b/wayland.c
@@ -315,15 +315,17 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
}
#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->wayl->viewporter != NULL) {
+ 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;
+ 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
@@ -351,8 +353,10 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
wl_surface_destroy(seat->pointer.surface.surf);
#if defined(HAVE_FRACTIONAL_SCALE)
- wp_viewport_destroy(seat->pointer.surface.viewport);
- seat->pointer.surface.viewport = NULL;
+ if (seat->pointer.surface.viewport != NULL) {
+ wp_viewport_destroy(seat->pointer.surface.viewport);
+ seat->pointer.surface.viewport = NULL;
+ }
#endif
if (seat->pointer.theme != NULL)