SDL: wayland: enable/disable ACTION_RESIZE for fullscreen

From 48066984b7248db0e96a63fee99e46bf1f2e3e68 Mon Sep 17 00:00:00 2001
From: Christian Rauch <[EMAIL REDACTED]>
Date: Mon, 5 Apr 2021 14:09:03 +0100
Subject: [PATCH] wayland: enable/disable ACTION_RESIZE for fullscreen

---
 src/video/wayland/SDL_waylanddyn.h    | 1 +
 src/video/wayland/SDL_waylandsym.h    | 2 ++
 src/video/wayland/SDL_waylandwindow.c | 8 ++++++++
 3 files changed, 11 insertions(+)

diff --git a/src/video/wayland/SDL_waylanddyn.h b/src/video/wayland/SDL_waylanddyn.h
index eef24a6dd1..7233fef66f 100644
--- a/src/video/wayland/SDL_waylanddyn.h
+++ b/src/video/wayland/SDL_waylanddyn.h
@@ -138,6 +138,7 @@ void SDL_WAYLAND_UnloadSymbols(void);
 #define libdecor_frame_unset_fullscreen (*WAYLAND_libdecor_frame_unset_fullscreen)
 #define libdecor_frame_set_capabilities (*WAYLAND_libdecor_frame_set_capabilities)
 #define libdecor_frame_unset_capabilities (*WAYLAND_libdecor_frame_unset_capabilities)
+#define libdecor_frame_has_capability (*WAYLAND_libdecor_frame_has_capability)
 #define libdecor_frame_map (*WAYLAND_libdecor_frame_map)
 #define libdecor_state_new (*WAYLAND_libdecor_state_new)
 #define libdecor_state_free (*WAYLAND_libdecor_state_free)
diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h
index 76b9c276f5..d6517f7f21 100644
--- a/src/video/wayland/SDL_waylandsym.h
+++ b/src/video/wayland/SDL_waylandsym.h
@@ -176,6 +176,8 @@ SDL_WAYLAND_SYM(void, libdecor_frame_set_capabilities, (struct libdecor_frame *,
                                                         enum libdecor_capabilities))
 SDL_WAYLAND_SYM(void, libdecor_frame_unset_capabilities, (struct libdecor_frame *, \
                                                           enum libdecor_capabilities))
+SDL_WAYLAND_SYM(bool, libdecor_frame_has_capability, (struct libdecor_frame *, \
+                                                      enum libdecor_capabilities))
 SDL_WAYLAND_SYM(void, libdecor_frame_map, (struct libdecor_frame *))
 SDL_WAYLAND_SYM(struct libdecor_state *, libdecor_state_new, (int, int))
 SDL_WAYLAND_SYM(void, libdecor_state_free, (struct libdecor_state *))
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index cc843c7181..88d3625f8c 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -136,9 +136,17 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
             return; /* Can't do anything yet, wait for ShowWindow */
         }
         if (output) {
+            if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
+                /* ensure that window is resizable before going into fullscreen */
+                libdecor_frame_set_capabilities(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE);
+            }
             libdecor_frame_set_fullscreen(wind->shell_surface.libdecor.frame, output);
         } else {
             libdecor_frame_unset_fullscreen(wind->shell_surface.libdecor.frame);
+            if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
+                /* restore previous RESIZE capability */
+                libdecor_frame_unset_capabilities(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE);
+            }
         }
     } else
 #endif