From 52459d2b8a68f77afda504da4e93887c8ed1fbd0 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 8 Sep 2022 13:20:54 -0400
Subject: [PATCH] Simplified the SDL_GetWMInfo-requests-SDL2-details code.
This patch written by @kjliew.
Fixes #186.
---
include/SDL/SDL_syswm.h | 2 +-
src/SDL12_compat.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/SDL/SDL_syswm.h b/include/SDL/SDL_syswm.h
index 007618d10..4321a07a0 100644
--- a/include/SDL/SDL_syswm.h
+++ b/include/SDL/SDL_syswm.h
@@ -109,7 +109,7 @@ real SDL-1.2 available to you. */
typedef struct SDL_SysWMinfo
{
SDL_version version;
- int data;
+ void *data;
} SDL_SysWMinfo;
# include "close_code.h"
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 9c0d81543..2a379826f 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -6981,6 +6981,16 @@ SDL_GetWMInfo(SDL12_SysWMinfo *info12)
int rc;
if (info12->version.major > 1) {
+ if (info12->version.major == 2) {
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
+ info12->window = (HWND)VideoWindow20;
+#elif defined(SDL_VIDEO_DRIVER_X11)
+ info12->info.x11.gfxdisplay = (Display *)VideoWindow20;
+#else
+ info12->data = (void *)VideoWindow20;
+#endif
+ return 1;
+ }
SDL20_SetError("Requested version is unsupported");
return 0; /* some programs only test against 0, not -1 */
} else if (!SupportSysWM) {