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.
This commit is contained in:
Frank Praznik 2024-01-04 13:55:57 -05:00
parent c03c01e9b2
commit 73d02184d7

View File

@ -1219,15 +1219,21 @@ 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 (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
```
becomes:
@ -1243,11 +1249,19 @@ becomes:
...
}
#elif defined(__LINUX__)
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
```