SDL: Re-set the maximize state if we were maximized while fullscreen

From 4556074e183a9a6249a98c7c2b01687f227178a0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 29 Oct 2022 09:35:07 -0700
Subject: [PATCH] Re-set the maximize state if we were maximized while
 fullscreen

---
 src/video/x11/SDL_x11window.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index a8d6a6505ee0..9b007e79d782 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -1388,13 +1388,17 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
 
         /* Fullscreen windows sometimes end up being marked maximized by
             window managers. Force it back to how we expect it to be. */
-        if (!fullscreen && ((window->flags & SDL_WINDOW_MAXIMIZED) == 0)) {
+        if (!fullscreen) {
             SDL_zero(e);
             e.xany.type = ClientMessage;
             e.xclient.message_type = _NET_WM_STATE;
             e.xclient.format = 32;
             e.xclient.window = data->xwindow;
-            e.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
+            if ((window->flags & SDL_WINDOW_MAXIMIZED) != 0) {
+                e.xclient.data.l[0] = _NET_WM_STATE_ADD;
+            } else {
+                e.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
+            }
             e.xclient.data.l[1] = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
             e.xclient.data.l[2] = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
             e.xclient.data.l[3] = 0l;