SDL: wayland: Avoid redundant SetWindowBordered for libdecor

From 8803589fc3f04a01a3605697c5fdac1161a97f0d Mon Sep 17 00:00:00 2001
From: Ethan Lee <[EMAIL REDACTED]>
Date: Mon, 2 Aug 2021 12:05:06 -0400
Subject: [PATCH] wayland: Avoid redundant SetWindowBordered for libdecor

---
 src/video/wayland/SDL_waylandwindow.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index e795b6305..1aace100f 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -713,7 +713,19 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
      * display, because we need to create the decorations before possibly hiding
      * them immediately afterward.
      */
-    Wayland_SetWindowBordered(_this, window, !(window->flags & SDL_WINDOW_BORDERLESS));
+#ifdef HAVE_LIBDECOR_H
+    if (c->shell.libdecor) {
+        /* ... but don't call it redundantly for libdecor, the decorator
+         * may not interpret a redundant call nicely and cause weird stuff to happen
+         */
+        if (window->flags & SDL_WINDOW_BORDERLESS) {
+            Wayland_SetWindowBordered(_this, window, SDL_FALSE);
+        }
+    } else
+#endif
+    {
+        Wayland_SetWindowBordered(_this, window, !(window->flags & SDL_WINDOW_BORDERLESS));
+    }
 
     /* We're finally done putting the window together, raise if possible */
     if (c->activation_manager) {