SDL: docs: Add Wayland to the SysWM migration example

From 73d02184d7426dc40216f44cfe88f188e8827ad1 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Thu, 4 Jan 2024 13:55:57 -0500
Subject: [PATCH] docs: Add Wayland to the SysWM migration example

Wayland will be increasingly encountered going forward and needs to be handled by applications requesting window handles to initialize the Vulkan WSI and such, so include it in the migration example to reflect current best practices.
---
 docs/README-migration.md | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/docs/README-migration.md b/docs/README-migration.md
index 5eb8b506d8c1..0bdde8fdaa03 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1219,14 +1219,20 @@ The information previously available in SDL_GetWindowWMInfo() is now available a
         ...
     }
 #elif defined(__LINUX__)
-    Display *xdisplay = NULL;
-    Window xwindow = 0;
-    if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_X11) {
-        xdisplay = info.info.x11.display;
-        xwindow = info.info.x11.window;
-    }
-    if (xdisplay && xwindow) {
-        ...
+    if (SDL_GetWindowWMInfo(window, &info)) {
+        if (info.subsystem == SDL_SYSWM_X11) {
+            Display *xdisplay = info.info.x11.display;
+            Window xwindow = info.info.x11.window;
+            if (xdisplay && xwindow) {
+                ...
+            }
+        } else if (info.subsystem == SDL_SYSWM_WAYLAND) {
+            struct wl_display *display = info.info.wl.display;
+            struct wl_surface *surface = info.info.wl.surface;
+            if (display && surface) {
+                ...
+            }
+        }
     }
 #endif

@@ -1243,10 +1249,18 @@ becomes:

}
#elif defined(LINUX)

  • Display *xdisplay = (Display *)SDL_GetProperty(SDL_GetWindowProperties(window), “SDL.window.x11.display”, NULL);
  • Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), “SDL.window.x11.window”, 0);
  • if (xdisplay && xwindow) {
  •    ...
    
  • if (SDL_strcmp(SDL_GetCurrentVideoDriver(), “x11”) == 0) {
  •    Display *xdisplay = (Display *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.x11.display", NULL);
    
  •    Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), "SDL.window.x11.window", 0);
    
  •    if (xdisplay && xwindow) {
    
  •        ...
    
  •    }
    
  • } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), “wayland”) == 0) {
  •    struct wl_display *display = (struct wl_display *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.wayland.display", NULL);
    
  •    struct wl_surface *surface = (struct wl_surface *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.wayland.surface", NULL);
    
  •    if (display && surface) {
    
  •        ...
    
  •    }
    
    }
    #endif