SDL: Fixed XSync sequence to match other cases where we set the X11 error handler

From b033cd0d2e02c8616e26471ce218aee356e927c3 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 31 Jul 2021 16:01:48 -0700
Subject: [PATCH] Fixed XSync sequence to match other cases where we set the
 X11 error handler

---
 src/video/x11/SDL_x11modes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index 0ac47b388..8a9cf56ed 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -1057,9 +1057,10 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode
            for now we cheat and just catch the X11 error and carry on, which
            is likely to cause subtle issues but is better than outright
            crashing */
+        X11_XSync(display, False);
         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_XSync(display, False);
         X11_XSetErrorHandler(PreXRRSetScreenSizeErrorHandler);
 
         status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime,