Commit 5733f42c7c2cbfbbd03282919534ed30c3b07da6

Sam Lantinga 2023-07-31T14:38:48

Fall back to Xlib if XRandR isn't available This fixes video initialization on headless systems with VNC Fixes https://github.com/libsdl-org/SDL/issues/8054 (cherry picked from commit 71099149b8fc062ea0ece232ccdd9f0ee9b3588b) (cherry picked from commit 8825fbf71391631f1a7ee7ca224a2f4e01cd8814)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index c952a0a..e3c24b2 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -643,8 +643,9 @@ int X11_InitModes(_THIS)
         int xrandr_major, xrandr_minor;
         /* require at least XRandR v1.3 */
         if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) &&
-            (xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3))) {
-            return X11_InitModes_XRandR(_this);
+            (xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3)) &&
+            X11_InitModes_XRandR(_this) == 0) {
+            return 0;
         }
     }
 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */