From 76c3f4c566b8133687261715bde89d23b2842bce Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 5 Dec 2022 13:56:39 -0500
Subject: [PATCH] syswm: Added stub for SDL_GetWindowWMInfo.
This is going to take some tapdancing to handle correctly, but for now just
report it as unsupported, since the interface is now incompatible with SDL2.
Reference Issue #2.
---
src/sdl2_compat.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
src/sdl3_syms.h | 2 +-
2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 0de7fdc..161cf9b 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -611,6 +611,51 @@ SDL_LOG_IMPL(Critical, CRITICAL)
#undef SDL_LOG_IMPL
+/* this enum changed in SDL3. */
+typedef enum
+{
+ SDL2_SYSWM_UNKNOWN,
+ SDL2_SYSWM_WINDOWS,
+ SDL2_SYSWM_X11,
+ SDL2_SYSWM_DIRECTFB,
+ SDL2_SYSWM_COCOA,
+ SDL2_SYSWM_UIKIT,
+ SDL2_SYSWM_WAYLAND,
+ SDL2_SYSWM_MIR,
+ SDL2_SYSWM_WINRT,
+ SDL2_SYSWM_ANDROID,
+ SDL2_SYSWM_VIVANTE,
+ SDL2_SYSWM_OS2,
+ SDL2_SYSWM_HAIKU,
+ SDL2_SYSWM_KMSDRM,
+ SDL2_SYSWM_RISCOS
+} SDL2_SYSWM_TYPE;
+
+#if 0
+static SDL2_SYSWM_TYPE
+SysWmType3to2(const SDL_SYSWM_TYPE typ3)
+{
+ switch (typ3) {
+ case SDL_SYSWM_UNKNOWN: return SDL2_SYSWM_UNKNOWN;
+ case SDL_SYSWM_ANDROID: return SDL2_SYSWM_ANDROID;
+ case SDL_SYSWM_COCOA: return SDL2_SYSWM_COCOA;
+ case SDL_SYSWM_HAIKU: return SDL2_SYSWM_HAIKU;
+ case SDL_SYSWM_KMSDRM: return SDL2_SYSWM_KMSDRM;
+ case SDL_SYSWM_RISCOS: return SDL2_SYSWM_RISCOS;
+ case SDL_SYSWM_UIKIT: return SDL2_SYSWM_UIKIT;
+ case SDL_SYSWM_VIVANTE: return SDL2_SYSWM_VIVANTE;
+ case SDL_SYSWM_WAYLAND: return SDL2_SYSWM_WAYLAND;
+ case SDL_SYSWM_WINDOWS: return SDL2_SYSWM_WINDOWS;
+ case SDL_SYSWM_WINRT: return SDL2_SYSWM_WINRT;
+ case SDL_SYSWM_X11: return SDL2_SYSWM_X11;
+ default: break;
+ }
+ return SDL2_SYSWM_UNKNOWN;
+}
+#endif
+
+
+/* stdio SDL_RWops was removed from SDL3, to prevent incompatible C runtime issues */
#if !HAVE_STDIO_H
DECLSPEC SDL_RWops * SDLCALL
SDL_RWFromFP(void *fp, SDL_bool autoclose)
@@ -870,6 +915,14 @@ SDLCALL SDL_GetTicks64(void)
return SDL3_GetTicks();
}
+DECLSPEC SDL_bool
+SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *wminfo)
+{
+ SDL3_Unsupported(); /* !!! FIXME: write me. */
+ return SDL_FALSE;
+}
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 9afe47b..631d87c 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -490,7 +490,7 @@ SDL3_SYM_PASSTHROUGH(int,LowerBlit,(SDL_Surface *a, SDL_Rect *b, SDL_Surface *c,
SDL3_SYM_PASSTHROUGH(int,SoftStretch,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
SDL3_SYM_PASSTHROUGH(int,UpperBlitScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
SDL3_SYM_PASSTHROUGH(int,LowerBlitScaled,(SDL_Surface *a, SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
-SDL3_SYM_PASSTHROUGH(SDL_bool,GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b),(a,b),return)
+SDL3_SYM(SDL_bool,GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b),(a,b),return)
SDL3_SYM_PASSTHROUGH(const char*,GetThreadName,(SDL_Thread *a),(a),return)
SDL3_SYM_PASSTHROUGH(SDL_threadID,ThreadID,(void),(),return)
SDL3_SYM_PASSTHROUGH(SDL_threadID,GetThreadID,(SDL_Thread *a),(a),return)