SDL: x11: Update the display when the WM changes a window's fullscreen state.

From 67e0f546c504a2914ac4f0e433aebe5b5e1f015a Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 15 Apr 2022 18:24:57 -0400
Subject: [PATCH] x11: Update the display when the WM changes a window's
 fullscreen state.

Fixes #5390.
---
 src/video/x11/SDL_x11events.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index 2beb252c0cf..eb46e4abe04 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -1449,11 +1449,15 @@ X11_DispatchEvent(_THIS, XEvent *xevent)
                     }
                 }
 
+                /* FULLSCREEN_DESKTOP encompasses two bits: SDL_WINDOW_FULLSCREEN, plus a bit to note it's FULLSCREEN_DESKTOP */
                 if (changed & SDL_WINDOW_FULLSCREEN_DESKTOP) {
-                    /* FULLSCREEN_DESKTOP encompasses two bits: SDL_WINDOW_FULLSCREEN, plus a bit to note it's FULLSCREEN_DESKTOP */
+                    SDL_VideoDisplay *viddisplay = SDL_GetDisplayForWindow(data->window);
                     const Uint32 fsmasked = flags & SDL_WINDOW_FULLSCREEN_DESKTOP;
                     data->window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
                     data->window->flags |= fsmasked;
+                    if (viddisplay) {
+                        viddisplay->fullscreen_window = fsmasked ? data->window : NULL;
+                    }
                 }
 
                 if (changed & SDL_WINDOW_MAXIMIZED) {