sdl12-compat: syswm: Added a quirk to disable SysWM interfaces.

From 63e4393d89482a87bfc91f849c6f32584cc7b21d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 10 Oct 2022 22:08:18 -0400
Subject: [PATCH] syswm: Added a quirk to disable SysWM interfaces.

And hooked up "fillets" to it.

Reference Issue #234.
---
 README.md          | 12 ++++++++++++
 src/SDL12_compat.c |  7 +++++++
 2 files changed, 19 insertions(+)

diff --git a/README.md b/README.md
index 0bab46856..434db4069 100644
--- a/README.md
+++ b/README.md
@@ -258,6 +258,18 @@ The available options are:
   completely ignored.
   The thread that called `SDL_SetVideoMode()` is treated as the main thread.
 
+- SDL12COMPAT_ALLOW_SYSWM: (checked during SDL_Init)
+  Enabled by default.
+  If disabled, SDL_SYSWMEVENT events will not be delivered to the app, and
+  SDL_GetWMInfo() will fail; this is useful if you have a program that
+  tries to access X11 directly through SDL's interfaces, but can survive
+  without it, becoming compatible with, for example, Wayland, or perhaps
+  just avoiding a bug in target-specific code. Note that sdl12-compat already
+  disallows SysWM things unless SDL2 is using its "windows" or "x11" video
+  backends, because SDL 1.2 didn't have wide support for its SysWM APIs
+  outside of Windows and X11 anyhow.
+
+
 # Compatibility issues with OpenGL scaling
 
 The OpenGL scaling feature of sdl12-compat allows applications which wish to
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index a49b1f9b1..b0fb649a4 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -1207,6 +1207,9 @@ static QuirkEntryType quirks[] = {
     {"tucnak", "SDL_RENDER_DRIVER", "software"},
     {"tucnak", "SDL_FRAMEBUFFER_ACCELERATION", "false"},
 
+    /* looks for X11 display and does unnecessary X11 things. Causes problems with SDL2/x11. */
+    {"fillets", "SDL12COMPAT_ALLOW_SYSWM", "0"},
+
     /* The 32-bit Steam build only of Multiwinia Quits but doesn't re-Init */
     {"multiwinia.bin.x86", "SDL12COMPAT_NO_QUIT_VIDEO", "1"}
 #else
@@ -2254,6 +2257,10 @@ Init12Video(void)
     SupportSysWM = SDL_FALSE;
 #endif
 
+    if (!SDL12Compat_GetHintBoolean("SDL12COMPAT_ALLOW_SYSWM", SDL_TRUE)) {
+        SupportSysWM = SDL_FALSE;
+    }
+
     SDL_EnableKeyRepeat(0, 0);
 
     SDL20_DelEventWatch(EventFilter20to12, NULL);