sdl12-compat: SDL_syswm.h only includes X11 headers if __has_include can find it.

From 4ad7ba6348d08d75496362efab1cbf099a6de42d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 19 Jun 2021 12:38:26 -0400
Subject: [PATCH] SDL_syswm.h only includes X11 headers if __has_include can
 find it.

This isn't a heavily-used feature of SDL 1.2 in general, but we can't promise
X11 is available in a generic sense (we can check for common Windows defines
before including windows.h, but common Unix platforms may or may not have Xlib
available).

In the name of avoiding a configure stage for the headers, we're saying this
only works if we're on a Unix platform (even if X11 is available elsewhere!)
and if the compiler has __has_include support (GCC 5+, Clang, etc).

Note that sdl12-compat itself doesn't currently pass on X11 syswm events, etc,
so it might just be worth dumping this completely and calling apps that rely
on it unsupported...it's entirely possible a given copy of the headers
wouldn't support it in real 1.2, too.
---
 include/SDL/SDL_syswm.h | 63 +++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/include/SDL/SDL_syswm.h b/include/SDL/SDL_syswm.h
index 6079a9b..dc645c8 100644
--- a/include/SDL/SDL_syswm.h
+++ b/include/SDL/SDL_syswm.h
@@ -32,41 +32,16 @@ real SDL-1.2 available to you. */
 
 #ifndef SDL_PROTOTYPES_ONLY
 
-#   if defined(__WIN32__)
-#       ifndef WIN32_LEAN_AND_MEAN
-#           define WIN32_LEAN_AND_MEAN
+#   if defined(unix) && !defined(__APPLE__) && defined(__has_include)
+#       if __has_include(<X11/Xlib.h>)
+#           define SDL12_COMPAT_SUPPORT_SYSWM_X11 1
 #       endif
-#       include <windows.h>
-
-#       include "begin_code.h"
-
-        typedef struct SDL_SysWMmsg
-        {
-            SDL_version version;
-            HWND hwnd;
-            UINT msg;
-            WPARAM wParam;
-            LPARAM lParam;
-        } SDL_SysWMmsg;
-
-        typedef struct SDL_SysWMinfo {
-            SDL_version version;
-            HWND window;
-            HGLRC hglrc;
-        } SDL_SysWMinfo;
-
-#       include "close_code.h"
-
-#   elif defined(unix)  /* shrug */
+#   endif
 
-#       ifdef __APPLE__
-#           define Cursor X11Cursor
-#       endif
+#   if defined(SDL12_COMPAT_SUPPORT_SYSWM_X11)
+#       undef SDL12_COMPAT_SUPPORT_SYSWM_X11
 #       include <X11/Xlib.h>
 #       include <X11/Xatom.h>
-#       ifdef __APPLE__
-#           undef Cursor
-#       endif
 
 #       include "begin_code.h"
 
@@ -102,6 +77,32 @@ real SDL-1.2 available to you. */
         } SDL_SysWMinfo;
 
 #       include "close_code.h"
+
+#   elif defined(__WIN32__)
+#       ifndef WIN32_LEAN_AND_MEAN
+#           define WIN32_LEAN_AND_MEAN
+#       endif
+#       include <windows.h>
+
+#       include "begin_code.h"
+
+        typedef struct SDL_SysWMmsg
+        {
+            SDL_version version;
+            HWND hwnd;
+            UINT msg;
+            WPARAM wParam;
+            LPARAM lParam;
+        } SDL_SysWMmsg;
+
+        typedef struct SDL_SysWMinfo {
+            SDL_version version;
+            HWND window;
+            HGLRC hglrc;
+        } SDL_SysWMinfo;
+
+#       include "close_code.h"
+
 #   else
 
 #       include "begin_code.h"