From 2bbd74b4b65a69e32d968a662536a72a0fcd7733 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Thu, 30 Oct 2025 12:03:07 +0000
Subject: [PATCH] wayland: Fix compile with libdecor 0.2 and
SDL_WAYLAND_LIBDECOR_SHARED=OFF
libdecor 0.3, which changes the signature of libdecor_new and
libdecor_decorate to use a const pointer to the interface struct, has
not yet been released. In the latest release, libdecor 0.2.4, the
interface struct is a mutable pointer.
This doesn't affect typical upstream builds with
SDL_WAYLAND_LIBDECOR_SHARED=ON, in which case we're casting a pointer
returned by dlsym(); but Linux distributions that want tighter control
over dependencies often prefer to link them in the normal way, in which
case the build will fail if the signature doesn't match.
Fixes: 33834360 "wayland: Fix libdecor incompatible pointer types"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8b64dd67d238e122057e4a454da786e53812ebec)
---
src/video/wayland/SDL_waylandsym.h | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h
index 4a4e4ceba2d4b..9cd260dae1a89 100644
--- a/src/video/wayland/SDL_waylandsym.h
+++ b/src/video/wayland/SDL_waylandsym.h
@@ -162,11 +162,19 @@ SDL_WAYLAND_SYM(const char *, xkb_keymap_layout_get_name, (struct xkb_keymap*, x
#ifdef HAVE_LIBDECOR_H
SDL_WAYLAND_MODULE(WAYLAND_LIBDECOR)
+
+#if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) || SDL_LIBDECOR_CHECK_VERSION(0, 3, 0)
+#define SDL_libdecor_constsince03 const
+#else
+#define SDL_libdecor_constsince03 /* nothing */
+#endif
+
SDL_WAYLAND_SYM(void, libdecor_unref, (struct libdecor *))
-SDL_WAYLAND_SYM(struct libdecor *, libdecor_new, (struct wl_display *, const struct libdecor_interface *))
+SDL_WAYLAND_SYM(struct libdecor *, libdecor_new, (struct wl_display *,\
+ SDL_libdecor_constsince03 struct libdecor_interface *))
SDL_WAYLAND_SYM(struct libdecor_frame *, libdecor_decorate, (struct libdecor *,\
struct wl_surface *,\
- const struct libdecor_frame_interface *,\
+ SDL_libdecor_constsince03 struct libdecor_frame_interface *,\
void *))
SDL_WAYLAND_SYM(void, libdecor_frame_unref, (struct libdecor_frame *))
SDL_WAYLAND_SYM(void, libdecor_frame_set_title, (struct libdecor_frame *, const char *))
@@ -232,6 +240,8 @@ SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_max_content_size, (const struct lib
SDL_WAYLAND_SYM_OPT(enum libdecor_wm_capabilities, libdecor_frame_get_wm_capabilities, (struct libdecor_frame *))
#endif
+#undef SDL_libdecor_constsince03
+
#endif
#undef SDL_WAYLAND_MODULE