sdl2-compat: Preserve behavior of https://github.com/libsdl-org/SDL/commit/120b8d4189d0979e4838daeb25d5a69e6260f5e0

From 45aeb26a5f9b0d54cb447bdf1ebe652bbc676218 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 12 Feb 2024 18:27:54 -0800
Subject: [PATCH] Preserve behavior of
 https://github.com/libsdl-org/SDL/commit/120b8d4189d0979e4838daeb25d5a69e6260f5e0

---
 src/sdl2_compat.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 429d606..e7a7464 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6022,6 +6022,7 @@ WindowPos2To3(int *x, int *y)
 DECLSPEC SDL_Window * SDLCALL
 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
 {
+    const char *driver;
     SDL_Window *window = NULL;
     const Uint32 is_popup = flags & (SDL_WINDOW_POPUP_MENU | SDL_WINDOW_TOOLTIP);
 
@@ -6036,6 +6037,14 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
         flags |= SDL_WINDOW_UTILITY;
     }
 
+    /* Preserve behavior in https://github.com/libsdl-org/SDL/commit/120b8d4189d0979e4838daeb25d5a69e6260f5e0 */
+    driver = SDL3_GetCurrentVideoDriver();
+    if (driver && SDL3_strcmp(driver, "wayland") == 0) {
+        if (!(flags & SDL_WINDOW_VULKAN)) {
+            flags |= SDL_WINDOW_OPENGL;
+        }
+    }
+
     if (!is_popup) {
         SDL_PropertiesID props = SDL3_CreateProperties();