SDL: SDL_syswm.h has been removed and replaced with window properties

From fd4a2cce9effc2cc5a69c4bd6fdc4622794ebf23 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 7 Nov 2023 14:38:19 -0800
Subject: [PATCH] SDL_syswm.h has been removed and replaced with window
 properties

---
 VisualC-GDK/SDL/SDL.vcxproj                   |   1 -
 VisualC-GDK/SDL/SDL.vcxproj.filters           |   3 -
 VisualC-WinRT/SDL-UWP.vcxproj                 |   1 -
 VisualC-WinRT/SDL-UWP.vcxproj.filters         |   3 -
 VisualC/SDL/SDL.vcxproj                       |   1 -
 VisualC/SDL/SDL.vcxproj.filters               |   3 -
 .../testautomation/testautomation.vcxproj     |   3 +-
 Xcode/SDL/SDL.xcodeproj/project.pbxproj       |   4 -
 docs/README-ios.md                            |  20 -
 docs/README-migration.md                      |  26 +-
 docs/README-winrt.md                          |   2 +-
 include/SDL3/SDL_events.h                     |  28 +-
 include/SDL3/SDL_hints.h                      |   1 -
 include/SDL3/SDL_oldnames.h                   |   2 -
 include/SDL3/SDL_system.h                     |  48 ++-
 include/SDL3/SDL_syswm.h                      | 387 ------------------
 include/SDL3/SDL_video.h                      |  49 +++
 include/build_config/SDL_build_config.h.cmake |  56 ---
 src/core/SDL_core_unsupported.c               |   8 +
 src/core/linux/SDL_fcitx.c                    |  19 +-
 src/core/linux/SDL_ibus.c                     |  21 +-
 src/dynapi/SDL_dynapi.c                       |   1 -
 src/dynapi/SDL_dynapi.sym                     |   2 +-
 src/dynapi/SDL_dynapi_overrides.h             |   2 +-
 src/dynapi/SDL_dynapi_procs.h                 |   2 +-
 src/events/SDL_events.c                       |  34 --
 src/events/SDL_events_c.h                     |   1 -
 src/render/direct3d/SDL_render_d3d.c          |  11 +-
 src/render/direct3d11/SDL_render_d3d11.c      |  15 +-
 src/render/direct3d11/SDL_render_winrt.cpp    |  25 +-
 src/render/direct3d12/SDL_render_d3d12.c      |  14 +-
 src/render/metal/SDL_render_metal.m           |  60 ++-
 src/video/SDL_sysvideo.h                      |   6 -
 src/video/SDL_video.c                         |  51 ---
 src/video/android/SDL_androidvideo.c          |   1 -
 src/video/android/SDL_androidvulkan.c         |   1 -
 src/video/android/SDL_androidwindow.c         |  18 +-
 src/video/android/SDL_androidwindow.h         |   1 -
 src/video/cocoa/SDL_cocoametalview.m          |   2 -
 src/video/cocoa/SDL_cocoavideo.m              |   1 -
 src/video/cocoa/SDL_cocoavulkan.m             |   2 -
 src/video/cocoa/SDL_cocoawindow.h             |   3 +-
 src/video/cocoa/SDL_cocoawindow.m             |  16 +-
 src/video/haiku/SDL_BWin.h                    |   2 -
 src/video/haiku/SDL_bvideo.cc                 |   1 -
 src/video/haiku/SDL_bwindow.cc                |   9 -
 src/video/haiku/SDL_bwindow.h                 |   1 -
 src/video/kmsdrm/SDL_kmsdrmvideo.c            |  23 +-
 src/video/kmsdrm/SDL_kmsdrmvideo.h            |   3 -
 src/video/kmsdrm/SDL_kmsdrmvulkan.c           |   2 -
 src/video/ngage/SDL_ngagewindow.h             |   9 +-
 src/video/psp/SDL_pspvideo.c                  |   2 -
 src/video/raspberry/SDL_rpivideo.c            |   2 -
 src/video/riscos/SDL_riscosvideo.c            |   1 -
 src/video/riscos/SDL_riscoswindow.c           |   8 -
 src/video/riscos/SDL_riscoswindow.h           |   1 -
 src/video/uikit/SDL_uikitmetalview.m          |   2 -
 src/video/uikit/SDL_uikitvideo.m              |   1 -
 src/video/uikit/SDL_uikitvulkan.m             |   2 -
 src/video/uikit/SDL_uikitwindow.h             |   3 +-
 src/video/uikit/SDL_uikitwindow.m             |  30 +-
 src/video/vita/SDL_vitavideo.c                |   2 -
 src/video/vivante/SDL_vivantevideo.c          |  22 +-
 src/video/vivante/SDL_vivantevideo.h          |   3 -
 src/video/vivante/SDL_vivantevulkan.c         |   1 -
 src/video/wayland/SDL_waylandvideo.c          |   1 -
 src/video/wayland/SDL_waylandvulkan.c         |   2 -
 src/video/wayland/SDL_waylandwindow.c         |  59 ++-
 src/video/wayland/SDL_waylandwindow.h         |   3 -
 src/video/windows/SDL_windowsevents.c         |  23 +-
 src/video/windows/SDL_windowsvideo.c          |   1 -
 src/video/windows/SDL_windowsvulkan.c         |   2 -
 src/video/windows/SDL_windowswindow.c         |  19 +-
 src/video/windows/SDL_windowswindow.h         |   1 -
 src/video/winrt/SDL_winrtvideo.cpp            |  14 +-
 src/video/x11/SDL_x11events.c                 |  45 +-
 src/video/x11/SDL_x11video.c                  |   1 -
 src/video/x11/SDL_x11window.c                 |  27 +-
 src/video/x11/SDL_x11window.h                 |   1 -
 test/testautomation.c                         |   1 -
 test/testautomation_suites.h                  |   1 -
 test/testautomation_syswm.c                   |  60 ---
 82 files changed, 277 insertions(+), 1069 deletions(-)
 delete mode 100644 include/SDL3/SDL_syswm.h
 delete mode 100644 test/testautomation_syswm.c

diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj
index b19bb5fba48e..a2c5aa6db280 100644
--- a/VisualC-GDK/SDL/SDL.vcxproj
+++ b/VisualC-GDK/SDL/SDL.vcxproj
@@ -345,7 +345,6 @@
     <ClInclude Include="..\..\include\SDL3\SDL_stdinc.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_surface.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_system.h" />
-    <ClInclude Include="..\..\include\SDL3\SDL_syswm.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_test.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_test_assert.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_test_common.h" />
diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters
index ba454f428fe1..a5772a745340 100644
--- a/VisualC-GDK/SDL/SDL.vcxproj.filters
+++ b/VisualC-GDK/SDL/SDL.vcxproj.filters
@@ -348,9 +348,6 @@
     <ClInclude Include="..\..\include\SDL3\SDL_system.h">
       <Filter>API Headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\include\SDL3\SDL_syswm.h">
-      <Filter>API Headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\include\SDL3\SDL_test.h">
       <Filter>API Headers</Filter>
     </ClInclude>
diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj
index 0dee306b691f..1085c0f45200 100644
--- a/VisualC-WinRT/SDL-UWP.vcxproj
+++ b/VisualC-WinRT/SDL-UWP.vcxproj
@@ -83,7 +83,6 @@
     <ClInclude Include="..\include\SDL3\SDL_stdinc.h" />
     <ClInclude Include="..\include\SDL3\SDL_surface.h" />
     <ClInclude Include="..\include\SDL3\SDL_system.h" />
-    <ClInclude Include="..\include\SDL3\SDL_syswm.h" />
     <ClInclude Include="..\include\SDL3\SDL_thread.h" />
     <ClInclude Include="..\include\SDL3\SDL_timer.h" />
     <ClInclude Include="..\include\SDL3\SDL_touch.h" />
diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters
index 7d765c13c113..ab0ca0cfb7ab 100644
--- a/VisualC-WinRT/SDL-UWP.vcxproj.filters
+++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters
@@ -147,9 +147,6 @@
     <ClInclude Include="..\include\SDL3\SDL_system.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\include\SDL3\SDL_syswm.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\include\SDL3\SDL_thread.h">
       <Filter>Header Files</Filter>
     </ClInclude>
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index 57eb07e85ca1..35edb9b8a6a4 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -296,7 +296,6 @@
     <ClInclude Include="..\..\include\SDL3\SDL_stdinc.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_surface.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_system.h" />
-    <ClInclude Include="..\..\include\SDL3\SDL_syswm.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_test.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_test_assert.h" />
     <ClInclude Include="..\..\include\SDL3\SDL_test_common.h" />
diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters
index cd7b2b2e3e17..b367e7695fe6 100644
--- a/VisualC/SDL/SDL.vcxproj.filters
+++ b/VisualC/SDL/SDL.vcxproj.filters
@@ -342,9 +342,6 @@
     <ClInclude Include="..\..\include\SDL3\SDL_system.h">
       <Filter>API Headers</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\include\SDL3\SDL_syswm.h">
-      <Filter>API Headers</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\include\SDL3\SDL_test.h">
       <Filter>API Headers</Filter>
     </ClInclude>
diff --git a/VisualC/tests/testautomation/testautomation.vcxproj b/VisualC/tests/testautomation/testautomation.vcxproj
index f64b89be8db2..260617b4a872 100644
--- a/VisualC/tests/testautomation/testautomation.vcxproj
+++ b/VisualC/tests/testautomation/testautomation.vcxproj
@@ -218,7 +218,6 @@
     <ClCompile Include="..\..\..\test\testautomation_sdltest.c" />
     <ClCompile Include="..\..\..\test\testautomation_stdlib.c" />
     <ClCompile Include="..\..\..\test\testautomation_surface.c" />
-    <ClCompile Include="..\..\..\test\testautomation_syswm.c" />
     <ClCompile Include="..\..\..\test\testautomation_timer.c" />
     <ClCompile Include="..\..\..\test\testautomation_video.c" />
     <ClCompile Include="..\..\..\test\testautomation_subsystems.c" />
@@ -229,4 +228,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index be5ba5ac43c4..657b54b2b1c0 100644
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -437,7 +437,6 @@
 		F3F7D9352933074E00816151 /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BC2933074A00816151 /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		F3F7D9392933074E00816151 /* SDL_opengles2_gl2ext.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BD2933074A00816151 /* SDL_opengles2_gl2ext.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		F3F7D93D2933074E00816151 /* SDL_endian.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BE2933074A00816151 /* SDL_endian.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		F3F7D9412933074E00816151 /* SDL_syswm.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BF2933074A00816151 /* SDL_syswm.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		F3F7D9452933074E00816151 /* SDL_opengl_glext.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8C02933074A00816151 /* SDL_opengl_glext.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		F3F7D9492933074E00816151 /* SDL_scancode.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8C12933074B00816151 /* SDL_scancode.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		F3F7D94D2933074E00816151 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8C22933074B00816151 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -939,7 +938,6 @@
 		F3F7D8BC2933074A00816151 /* SDL_error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_error.h; path = SDL3/SDL_error.h; sourceTree = "<group>"; };
 		F3F7D8BD2933074A00816151 /* SDL_opengles2_gl2ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_opengles2_gl2ext.h; path = SDL3/SDL_opengles2_gl2ext.h; sourceTree = "<group>"; };
 		F3F7D8BE2933074A00816151 /* SDL_endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_endian.h; path = SDL3/SDL_endian.h; sourceTree = "<group>"; };
-		F3F7D8BF2933074A00816151 /* SDL_syswm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_syswm.h; path = SDL3/SDL_syswm.h; sourceTree = "<group>"; };
 		F3F7D8C02933074A00816151 /* SDL_opengl_glext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_opengl_glext.h; path = SDL3/SDL_opengl_glext.h; sourceTree = "<group>"; };
 		F3F7D8C12933074B00816151 /* SDL_scancode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scancode.h; path = SDL3/SDL_scancode.h; sourceTree = "<group>"; };
 		F3F7D8C22933074B00816151 /* SDL_sensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_sensor.h; path = SDL3/SDL_sensor.h; sourceTree = "<group>"; };
@@ -1091,7 +1089,6 @@
 				F3F7D8AC2933074900816151 /* SDL_stdinc.h */,
 				F3F7D8BB2933074A00816151 /* SDL_surface.h */,
 				F3F7D8E82933074E00816151 /* SDL_system.h */,
-				F3F7D8BF2933074A00816151 /* SDL_syswm.h */,
 				F3F7D8CD2933074C00816151 /* SDL_thread.h */,
 				F3F7D8B22933074900816151 /* SDL_timer.h */,
 				F3F7D8AF2933074900816151 /* SDL_touch.h */,
@@ -2259,7 +2256,6 @@
 				A7D8B42823E2514300DCD162 /* SDL_systhread_c.h in Headers */,
 				5616CA4D252BB2A6005D5928 /* SDL_sysurl.h in Headers */,
 				A7D8AC3F23E2514100DCD162 /* SDL_sysvideo.h in Headers */,
-				F3F7D9412933074E00816151 /* SDL_syswm.h in Headers */,
 				F3F7D9792933074E00816151 /* SDL_thread.h in Headers */,
 				A7D8B3EC23E2514300DCD162 /* SDL_thread_c.h in Headers */,
 				F3F7D90D2933074E00816151 /* SDL_timer.h in Headers */,
diff --git a/docs/README-ios.md b/docs/README-ios.md
index 643b342ea672..6e48af943471 100644
--- a/docs/README-ios.md
+++ b/docs/README-ios.md
@@ -125,26 +125,6 @@ SDL for iPhone supports polling the built in accelerometer as a joystick device.
 The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_GetJoystickAxis() reports joystick values as signed integers.  Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver.  To convert SDL_GetJoystickAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
 
 
-Notes -- OpenGL ES
-==============================================================================
-
-Your SDL application for iOS uses OpenGL ES for video by default.
-
-OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute().
-
-If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
-
-Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0.
-
-OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this:
-
-- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow() is called.
-- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow() is called.
-- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called.
-
-The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
-
-
 Notes -- Keyboard
 ==============================================================================
 
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 60b9209c7baf..3bd20f135b1f 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1150,6 +1150,8 @@ The following functions have been renamed:
 
 ## SDL_system.h
 
+SDL_WindowsMessageHook has changed signatures so the message may be modified and it can block further message processing.
+
 SDL_AndroidGetExternalStorageState() takes the state as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.
 
 The following functions have been removed:
@@ -1159,7 +1161,29 @@ The following functions have been removed:
 
 ## SDL_syswm.h
 
-The structures in this file are versioned separately from the rest of SDL, allowing better backwards compatibility and limited forwards compatibility with your application. Instead of calling `SDL_VERSION(&info.version)` before calling SDL_GetWindowWMInfo(), you pass the version in explicitly as SDL_SYSWM_CURRENT_VERSION so SDL knows what fields you expect to be filled out.
+This header has been removed.
+
+The Windows and X11 events are now available via callbacks which you can set with SDL_SetWindowsMessageHook() and SDL_SetX11EventHook().
+
+The information previously available in SDL_GetWindowWMInfo() is now available as window properties, e.g.
+```c
+    HWND hwnd = NULL;
+    SDL_SysWMinfo info;
+    SDL_VERSION(&info);
+    if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_WINDOWS) {
+        hwnd = info.info.win.window;
+    }
+    if (hwnd) {
+        ...
+    }
+```
+becomes:
+```c
+    HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd");
+    if (hwnd) {
+        ...
+    }
+```
 
 ### SDL_GetWindowWMInfo
 
diff --git a/docs/README-winrt.md b/docs/README-winrt.md
index 3530f673e04e..61922640981a 100644
--- a/docs/README-winrt.md
+++ b/docs/README-winrt.md
@@ -63,7 +63,7 @@ Here is a rough list of what works, and what doesn't:
   * using Direct3D 11.x APIs outside of SDL.  Non-XAML / Direct3D-only apps can
     choose to render content directly via Direct3D, using SDL to manage the
     internal WinRT window, as well as input and audio.  (Use
-    SDL_GetWindowWMInfo() to get the WinRT 'CoreWindow', and pass it into
+    the window properties to get the WinRT 'CoreWindow', and pass it into
     IDXGIFactory2::CreateSwapChainForCoreWindow() as appropriate.)
 
 * What partially works:
diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h
index 427e9416b7a4..dcc9ece04a72 100644
--- a/include/SDL3/SDL_events.h
+++ b/include/SDL3/SDL_events.h
@@ -101,8 +101,8 @@ typedef enum
 
     /* Window events */
     /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */
-    SDL_EVENT_SYSWM     = 0x201,        /**< System specific event */
-    SDL_EVENT_WINDOW_SHOWN,             /**< Window has been shown */
+    /* 0x201 was SDL_EVENT_SYSWM, reserve the number for sdl2-compat */
+    SDL_EVENT_WINDOW_SHOWN = 0x202,     /**< Window has been shown */
     SDL_EVENT_WINDOW_HIDDEN,            /**< Window has been hidden */
     SDL_EVENT_WINDOW_EXPOSED,           /**< Window has been exposed and should be redrawn */
     SDL_EVENT_WINDOW_MOVED,             /**< Window has been moved to data1, data2 */
@@ -573,27 +573,6 @@ typedef struct SDL_UserEvent
 } SDL_UserEvent;
 
 
-struct SDL_SysWMmsg;
-typedef struct SDL_SysWMmsg SDL_SysWMmsg;
-
-/**
- * A video driver dependent system event (event.syswm.*)
- *
- * This event is disabled by default, you can enable it with
- * SDL_SetEventEnabled()
- *
- * The `msg` is owned by SDL and should be copied if the application
- * wants to hold onto it beyond the scope of handling this event.
- *
- * \note If you want to use this event, you should include SDL_syswm.h.
- */
-typedef struct SDL_SysWMEvent
-{
-    Uint32 type;        /**< ::SDL_EVENT_SYSWM */
-    Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
-    SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
-} SDL_SysWMEvent;
-
 /**
  *  General event structure
  */
@@ -623,10 +602,9 @@ typedef union SDL_Event
     SDL_SensorEvent sensor;                 /**< Sensor event data */
     SDL_QuitEvent quit;                     /**< Quit request event data */
     SDL_UserEvent user;                     /**< Custom event data */
-    SDL_SysWMEvent syswm;                   /**< System dependent window event data */
     SDL_TouchFingerEvent tfinger;           /**< Touch finger event data */
     SDL_DropEvent drop;                     /**< Drag and drop event data */
-    SDL_ClipboardEvent clipboard;       /**< Clipboard cancelled event data */
+    SDL_ClipboardEvent clipboard;           /**< Clipboard event data */
 
     /* This is necessary for ABI compatibility between Visual C++ and GCC.
        Visual C++ will respect the push pack pragma and use 52 bytes (size of
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index a4933ac77bba..a2d06b2b18fb 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -417,7 +417,6 @@ extern "C" {
  *    "0"     - Don't log any events (default)
  *    "1"     - Log most events (other than the really spammy ones).
  *    "2"     - Include mouse and finger motion events.
- *    "3"     - Include SDL_SysWMEvent events.
  *
  *  This is generally meant to be used to debug SDL itself, but can be useful
  *  for application developers that need better visibility into what is going
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 5e266c115595..805921292bbb 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -124,7 +124,6 @@
 #define SDL_RENDER_DEVICE_RESET SDL_EVENT_RENDER_DEVICE_RESET
 #define SDL_RENDER_TARGETS_RESET SDL_EVENT_RENDER_TARGETS_RESET
 #define SDL_SENSORUPDATE SDL_EVENT_SENSOR_UPDATE
-#define SDL_SYSWMEVENT SDL_EVENT_SYSWM
 #define SDL_TEXTEDITING SDL_EVENT_TEXT_EDITING
 #define SDL_TEXTEDITING_EXT SDL_EVENT_TEXT_EDITING_EXT
 #define SDL_TEXTINPUT SDL_EVENT_TEXT_INPUT
@@ -568,7 +567,6 @@
 #define SDL_RENDER_DEVICE_RESET SDL_RENDER_DEVICE_RESET_renamed_SDL_EVENT_RENDER_DEVICE_RESET
 #define SDL_RENDER_TARGETS_RESET SDL_RENDER_TARGETS_RESET_renamed_SDL_EVENT_RENDER_TARGETS_RESET
 #define SDL_SENSORUPDATE SDL_SENSORUPDATE_renamed_SDL_EVENT_SENSOR_UPDATE
-#define SDL_SYSWMEVENT SDL_SYSWMEVENT_renamed_SDL_EVENT_SYSWM
 #define SDL_TEXTEDITING SDL_TEXTEDITING_renamed_SDL_EVENT_TEXT_EDITING
 #define SDL_TEXTEDITING_EXT SDL_TEXTEDITING_EXT_renamed_SDL_EVENT_TEXT_EDITING_EXT
 #define SDL_TEXTINPUT SDL_TEXTINPUT_renamed_SDL_EVENT_TEXT_INPUT
diff --git a/include/SDL3/SDL_system.h b/include/SDL3/SDL_system.h
index 14a25e00a13f..a2cd27d8704c 100644
--- a/include/SDL3/SDL_system.h
+++ b/include/SDL3/SDL_system.h
@@ -40,14 +40,18 @@ extern "C" {
 #endif
 
 
-/* Platform specific functions for Windows */
+/*
+ * Platform specific functions for Windows
+ */
 #if defined(__WIN32__) || defined(__GDK__)
 
-typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
-
+typedef struct tagMSG MSG;
+typedef SDL_bool (SDLCALL *SDL_WindowsMessageHook)(void *userdata, MSG *msg);
 /**
  * Set a callback for every Windows message, run before TranslateMessage().
  *
+ * The callback may modify the message, and should return SDL_TRUE if the message should continue to be processed, or SDL_FALSE to prevent further processing.
+ *
  * \param callback The SDL_WindowsMessageHook function to call.
  * \param userdata a pointer to pass to every iteration of `callback`
  *
@@ -96,7 +100,27 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID,
 
 #endif /* defined(__WIN32__) || defined(__WINGDK__) */
 
-/* Platform specific functions for Linux */
+/*
+ * Platform specific functions for UNIX
+ */
+
+typedef union _XEvent XEvent;
+typedef SDL_bool (SDLCALL *SDL_X11EventHook)(void *userdata, XEvent *xevent);
+/**
+ * Set a callback for every X11 event
+ *
+ * The callback may modify the event, and should return SDL_TRUE if the event should continue to be processed, or SDL_FALSE to prevent further processing.
+ *
+ * \param callback The SDL_X11EventHook function to call.
+ * \param userdata a pointer to pass to every iteration of `callback`
+ *
+ * \since This function is available since SDL 3.0.0.
+ */
+extern DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata);
+
+/*
+ * Platform specific functions for Linux
+ */
 #ifdef __LINUX__
 
 /**
@@ -130,7 +154,9 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
 
 #endif /* __LINUX__ */
 
-/* Platform specific functions for iOS */
+/*
+ * Platform specific functions for iOS
+ */
 #ifdef __IOS__
 
 #define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
@@ -190,7 +216,9 @@ extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
 #endif /* __IOS__ */
 
 
-/* Platform specific functions for Android */
+/*
+ * Platform specific functions for Android
+ */
 #ifdef __ANDROID__
 
 /**
@@ -419,7 +447,9 @@ extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
 
 #endif /* __ANDROID__ */
 
-/* Platform specific functions for WinRT */
+/*
+ * Platform specific functions for WinRT
+ */
 #ifdef __WINRT__
 
 /**
@@ -581,7 +611,9 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void);
 extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
 #endif
 
-/* Functions used only by GDK */
+/*
+ * Functions used only by GDK
+ */
 #ifdef __GDK__
 typedef struct XTaskQueueObject *XTaskQueueHandle;
 typedef struct XUser *XUserHandle;
diff --git a/include/SDL3/SDL_syswm.h b/include/SDL3/SDL_syswm.h
deleted file mode 100644
index cefe98077c9a..000000000000
--- a/include/SDL3/SDL_syswm.h
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-
-/**
- *  \file SDL_syswm.h
- *
- *  Include file for SDL custom system window manager hooks.
- */
-
-#ifndef SDL_syswm_h_
-#define SDL_syswm_h_
-
-#include <SDL3/SDL_stdinc.h>
-#include <SDL3/SDL_error.h>
-#include <SDL3/SDL_platform_defines.h>
-#include <SDL3/SDL_video.h>
-
-/**
- *  SDL_syswm.h
- *
- *  Your application has access to a special type of event ::SDL_EVENT_SYSWM,
- *  which contains window-manager specific information and arrives whenever
- *  an unhandled window event occurs.  This event is ignored by default, but
- *  you can enable it with SDL_SetEventEnabled().
- */
-
-/**
- *  The available subsystems based on platform
- */
-#ifndef SDL_DISABLE_SYSWM_PLATFORMS
-
-#ifndef SDL_DISABLE_SYSWM_ANDROID
-#ifdef __ANDROID__
-#define SDL_ENABLE_SYSWM_ANDROID
-#endif
-#endif /* !SDL_DISABLE_SYSWM_ANDROID */
-
-#ifndef SDL_DISABLE_SYSWM_COCOA
-#ifdef __MACOS__
-#define SDL_ENABLE_SYSWM_COCOA
-#endif
-#endif /* !SDL_DISABLE_SYSWM_COCOA */
-
-#ifndef SDL_DISABLE_SYSWM_HAIKU
-#ifdef __HAIKU__
-#define SDL_ENABLE_SYSWM_HAIKU
-#endif
-#endif /* !SDL_DISABLE_SYSWM_HAIKU */
-
-#ifndef SDL_DISABLE_SYSWM_KMSDRM
-#if defined(__LINUX__) || defined(__FREEBSD__) || defined(__OPENBSD__)
-#define SDL_ENABLE_SYSWM_KMSDRM
-#endif
-#endif /* !SDL_DISABLE_SYSWM_KMSDRM */
-
-#ifndef SDL_DISABLE_SYSWM_RISCOS
-#ifdef __RISCOS__
-#define SDL_ENABLE_SYSWM_RISCOS
-#endif
-#endif /* !SDL_DISABLE_SYSWM_RISCOS */
-
-#ifndef SDL_DISABLE_SYSWM_UIKIT
-#if defined(__IOS__) || defined(__TVOS__)
-#define SDL_ENABLE_SYSWM_UIKIT
-#endif
-#endif /* !SDL_DISABLE_SYSWM_UIKIT */
-
-#ifndef SDL_DISABLE_SYSWM_VIVANTE
-/* Not enabled by default */
-#endif /* !SDL_DISABLE_SYSWM_VIVANTE */
-
-#ifndef SDL_DISABLE_SYSWM_WAYLAND
-#if defined(__LINUX__) || defined(__FREEBSD__)
-#define SDL_ENABLE_SYSWM_WAYLAND
-#endif
-#endif /* !SDL_DISABLE_SYSWM_WAYLAND */
-
-#ifndef SDL_DISABLE_SYSWM_WINDOWS
-#if defined(__WIN32__) || defined(__GDK__)
-#define SDL_ENABLE_SYSWM_WINDOWS
-#endif
-#endif /* !SDL_DISABLE_SYSWM_WINDOWS */
-
-#ifndef SDL_DISABLE_SYSWM_WINRT
-#ifdef __WINRT__
-#define SDL_ENABLE_SYSWM_WINRT
-#endif
-#endif /* !SDL_DISABLE_SYSWM_WINRT */
-
-#ifndef SDL_DISABLE_SYSWM_X11
-#if defined(__unix__) && !defined(__WIN32__) && !defined(__ANDROID__) && !defined(__QNX__)
-#define SDL_ENABLE_SYSWM_X11
-#endif
-#endif /* !SDL_DISABLE_SYSWM_X11 */
-
-#endif /* !SDL_DISABLE_SYSWM_PLATFORMS */
-
-/**
- *  Forward declaration of types used by subsystems
- */
-#ifndef SDL_DISABLE_SYSWM_TYPES
-
-#if defined(SDL_ENABLE_SYSWM_ANDROID) && !defined(SDL_DISABLE_SYSWM_ANDROID_TYPES)
-typedef struct ANativeWindow ANativeWindow;
-typedef void *EGLSurface;
-#endif /* SDL_ENABLE_SYSWM_ANDROID */
-
-#if defined(SDL_ENABLE_SYSWM_COCOA) && !defined(SDL_DISABLE_SYSWM_COCOA_TYPES)
-#ifdef __OBJC__
-@class NSWindow;
-#else
-typedef struct _NSWindow NSWindow;
-#endif
-#endif /* SDL_ENABLE_SYSWM_COCOA */
-
-#if defined(SDL_ENABLE_SYSWM_KMSDRM) && !defined(SDL_DISABLE_SYSWM_KMSDRM_TYPES)
-struct gbm_device;
-#endif /* SDL_ENABLE_SYSWM_KMSDRM */
-
-#if defined(SDL_ENABLE_SYSWM_UIKIT) && !defined(SDL_DISABLE_SYSWM_UIKIT_TYPES)
-#ifdef __OBJC__
-#include <UIKit/UIKit.h>
-#else
-typedef struct _UIWindow UIWindow;
-typedef struct _UIViewController UIViewController;
-#endif
-typedef Uint32 GLuint;
-#endif /* SDL_ENABLE_SYSWM_UIKIT */
-
-#if defined(SDL_ENABLE_SYSWM_VIVANTE) && !defined(SDL_DISABLE_SYSWM_VIVANTE_TYPES)
-#include <SDL3/SDL_egl.h>
-#endif /* SDL_ENABLE_SYSWM_VIVANTE */
-
-#if defined(SDL_ENABLE_SYSWM_WAYLAND) && !defined(SDL_DISABLE_SYSWM_WAYLAND_TYPES)
-struct wl_display;
-struct wl_egl_window;
-struct wl_surface;
-struct xdg_popup;
-struct xdg_positioner;
-struct xdg_surface;
-struct xdg_toplevel;
-#endif /* SDL_ENABLE_SYSWM_WAYLAND */
-
-#if defined(SDL_ENABLE_SYSWM_WINDOWS) && !defined(SDL_DISABLE_SYSWM_WINDOWS_TYPES)
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#ifndef NOMINMAX   /* don't define min() and max(). */
-#define NOMINMAX
-#endif
-#include <windows.h>
-#endif /* SDL_ENABLE_SYSWM_WINDOWS */
-
-#if defined(SDL_ENABLE_SYSWM_WINRT) && !defined(SDL_DISABLE_SYSWM_WINRT_TYPES)
-#include <Inspectable.h>
-#endif /* SDL_ENABLE_SYSWM_WINRT */
-
-#if defined(SDL_ENABLE_SYSWM_X11) && !defined(SDL_DISABLE_SYSWM_X11_TYPES)
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#endif /* SDL_ENABLE_SYSWM_X11 */
-
-#endif /* !SDL_DISABLE_SYSWM_TYPES */
-
-
-#include <SDL3/SDL_begin_code.h>
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* This is the current version of structures in this file */
-#define SDL_SYSWM_CURRENT_VERSION   1
-#define SDL_SYSWM_INFO_SIZE_V1      (16 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)))
-#define SDL_SYSWM_CURRENT_INFO_SIZE SDL_SYSWM_INFO_SIZE_V1
-
-/* This is the tag associated with a Metal view so you can find it */
-#define SDL_METALVIEW_TAG 255
-
-
-/**
- *  These 

(Patch may be truncated, please check the link at the top of this post.)