SDL: x11: XSync while trying to catch XRRSetScreenSize error.

From 4c7825f6bd81f2d245cbd086544bc1da8f3e7e84 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 31 Jul 2021 18:27:14 -0400
Subject: [PATCH] x11: XSync while trying to catch XRRSetScreenSize error.

Reference issue #4561
---
 src/video/x11/SDL_x11modes.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index 7dab9ff5a..0ac47b388 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -1059,6 +1059,7 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode
            crashing */
         PreXRRSetScreenSizeErrorHandler = X11_XSetErrorHandler(SDL_XRRSetScreenSizeErrHandler);
         X11_XRRSetScreenSize(display, RootWindow(display, data->screen), mode->w, mode->h, mm_width, mm_height);
+        X11_XSync(display, False);  /* hopefully force any protocol errors to process with this handler. */
         X11_XSetErrorHandler(PreXRRSetScreenSizeErrorHandler);
 
         status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime,