From 7e4d14d47a110254721228e162f7ff17f4293c1f Mon Sep 17 00:00:00 2001 From: Sam Lantinga 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 | 46 +++ 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 | 18 +- 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 | 25 +- src/video/x11/SDL_x11window.h | 1 - test/testautomation.c | 1 - test/testautomation_suites.h | 1 - test/testautomation_syswm.c | 60 --- 82 files changed, 270 insertions(+), 1068 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 b19bb5fba48ee4..a2c5aa6db28038 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj +++ b/VisualC-GDK/SDL/SDL.vcxproj @@ -345,7 +345,6 @@ - diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters index ba454f428fe1eb..a5772a74534092 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj.filters +++ b/VisualC-GDK/SDL/SDL.vcxproj.filters @@ -348,9 +348,6 @@ API Headers - - API Headers - API Headers diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj index 0dee306b691fdc..1085c0f4520074 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj +++ b/VisualC-WinRT/SDL-UWP.vcxproj @@ -83,7 +83,6 @@ - diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters index 7d765c13c113ae..ab0ca0cfb7ab8a 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters @@ -147,9 +147,6 @@ Header Files - - Header Files - Header Files diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj index 57eb07e85ca1c0..35edb9b8a6a446 100644 --- a/VisualC/SDL/SDL.vcxproj +++ b/VisualC/SDL/SDL.vcxproj @@ -296,7 +296,6 @@ - diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters index cd7b2b2e3e1764..b367e7695fe645 100644 --- a/VisualC/SDL/SDL.vcxproj.filters +++ b/VisualC/SDL/SDL.vcxproj.filters @@ -342,9 +342,6 @@ API Headers - - API Headers - API Headers diff --git a/VisualC/tests/testautomation/testautomation.vcxproj b/VisualC/tests/testautomation/testautomation.vcxproj index f64b89be8db2db..260617b4a87232 100644 --- a/VisualC/tests/testautomation/testautomation.vcxproj +++ b/VisualC/tests/testautomation/testautomation.vcxproj @@ -218,7 +218,6 @@ - @@ -229,4 +228,4 @@ - \ No newline at end of file + diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index be5ba5ac43c4f5..657b54b2b1c0be 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 = ""; }; 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 = ""; }; F3F7D8BE2933074A00816151 /* SDL_endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_endian.h; path = SDL3/SDL_endian.h; sourceTree = ""; }; - F3F7D8BF2933074A00816151 /* SDL_syswm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_syswm.h; path = SDL3/SDL_syswm.h; sourceTree = ""; }; 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 = ""; }; F3F7D8C12933074B00816151 /* SDL_scancode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scancode.h; path = SDL3/SDL_scancode.h; sourceTree = ""; }; F3F7D8C22933074B00816151 /* SDL_sensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_sensor.h; path = SDL3/SDL_sensor.h; sourceTree = ""; }; @@ -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 643b342ea67295..6e48af94347137 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 60b9209c7baff7..3bd20f135b1f8b 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 3530f673e04e25..61922640981a24 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 427e9416b7a497..dcc9ece04a7225 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 a4933ac77bba0a..a2d06b2b18fb08 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 5e266c11559541..805921292bbba7 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 14a25e00a13f1e..a2cd27d8704cd7 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 cefe98077c9a8e..00000000000000 --- a/include/SDL3/SDL_syswm.h +++ /dev/null @@ -1,387 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - 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 -#include -#include -#include - -/** - * 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 -#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 -#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 -#endif /* SDL_ENABLE_SYSWM_WINDOWS */ - -#if defined(SDL_ENABLE_SYSWM_WINRT) && !defined(SDL_DISABLE_SYSWM_WINRT_TYPES) -#include -#endif /* SDL_ENABLE_SYSWM_WINRT */ - -#if defined(SDL_ENABLE_SYSWM_X11) && !defined(SDL_DISABLE_SYSWM_X11_TYPES) -#include -#include -#endif /* SDL_ENABLE_SYSWM_X11 */ - -#endif /* !SDL_DISABLE_SYSWM_TYPES */ - - -#include -/* 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 are the various supported windowing subsystems - */ -typedef enum -{ - SDL_SYSWM_UNKNOWN, - SDL_SYSWM_ANDROID, - SDL_SYSWM_COCOA, - SDL_SYSWM_HAIKU, - SDL_SYSWM_KMSDRM, - SDL_SYSWM_RISCOS, - SDL_SYSWM_UIKIT, - SDL_SYSWM_VIVANTE, - SDL_SYSWM_WAYLAND, - SDL_SYSWM_WINDOWS, - SDL_SYSWM_WINRT, - SDL_SYSWM_X11 -} SDL_SYSWM_TYPE; - -/** - * The custom event structure. - */ -struct SDL_SysWMmsg -{ - Uint32 version; - Uint32 subsystem; /**< SDL_SYSWM_TYPE */ - - Uint32 padding[(2 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)) - 2 * sizeof(Uint32)) / sizeof(Uint32)]; - - union - { -#ifdef SDL_ENABLE_SYSWM_WINDOWS - struct { - HWND hwnd; /**< The window for the message */ - UINT msg; /**< The type of message */ - WPARAM wParam; /**< WORD message parameter */ - LPARAM lParam; /**< LONG message parameter */ - } win; -#endif -#ifdef SDL_ENABLE_SYSWM_X11 - struct { - XEvent event; - } x11; -#endif - /* Can't have an empty union */ - int dummy; - } msg; -}; - -/** - * The custom window manager information structure. - * - * When this structure is returned, it holds information about which - * low level system it is using, and will be one of SDL_SYSWM_TYPE. - */ -struct SDL_SysWMinfo -{ - Uint32 version; - Uint32 subsystem; /**< SDL_SYSWM_TYPE */ - - Uint32 padding[(2 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)) - 2 * sizeof(Uint32)) / sizeof(Uint32)]; - - union - { -#ifdef SDL_ENABLE_SYSWM_WINDOWS - struct - { - HWND window; /**< The window handle */ - HDC hdc; /**< The window device context */ - HINSTANCE hinstance; /**< The instance handle */ - } win; -#endif -#ifdef SDL_ENABLE_SYSWM_WINRT - struct - { - IInspectable * window; /**< The WinRT CoreWindow */ - } winrt; -#endif -#ifdef SDL_ENABLE_SYSWM_X11 - struct - { - Display *display; /**< The X11 display */ - int screen; /**< The X11 screen */ - Window window; /**< The X11 window */ - } x11; -#endif -#ifdef SDL_ENABLE_SYSWM_COCOA - struct - { -#if defined(__OBJC__) && defined(__has_feature) - #if __has_feature(objc_arc) - NSWindow __unsafe_unretained *window; /**< The Cocoa window */ - #else - NSWindow *window; /**< The Cocoa window */ - #endif -#else - NSWindow *window; /**< The Cocoa window */ -#endif - } cocoa; -#endif -#ifdef SDL_ENABLE_SYSWM_UIKIT - struct - { -#if defined(__OBJC__) && defined(__has_feature) - #if __has_feature(objc_arc) - UIWindow __unsafe_unretained *window; /**< The UIKit window */ - #else - UIWindow *window; /**< The UIKit window */ - #endif -#else - UIWindow *window; /**< The UIKit window */ -#endif - GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */ - GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */ - GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */ - } uikit; -#endif -#ifdef SDL_ENABLE_SYSWM_WAYLAND - struct - { - struct wl_display *display; /**< Wayland display */ - struct wl_surface *surface; /**< Wayland surface */ - struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */ - struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */ - struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */ - struct xdg_popup *xdg_popup; /**< Wayland xdg popup role */ - struct xdg_positioner *xdg_positioner; /**< Wayland xdg positioner, for popup */ - } wl; -#endif - -#ifdef SDL_ENABLE_SYSWM_ANDROID - struct - { - ANativeWindow *window; - EGLSurface surface; - } android; -#endif - -#ifdef SDL_ENABLE_SYSWM_VIVANTE - struct - { - EGLNativeDisplayType display; - EGLNativeWindowType window; - } vivante; -#endif - -#ifdef SDL_ENABLE_SYSWM_KMSDRM - struct - { - int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */ - int drm_fd; /**< DRM FD (unavailable on Vulkan windows) */ - struct gbm_device *gbm_dev; /**< GBM device (unavailable on Vulkan windows) */ - } kmsdrm; -#endif - - /* Make sure this union has enough room for 14 pointers */ - void *dummy_ptrs[14]; - Uint64 dummy_ints[14]; - } info; -}; -SDL_COMPILE_TIME_ASSERT(SDL_SysWMinfo_size, sizeof(struct SDL_SysWMinfo) == SDL_SYSWM_CURRENT_INFO_SIZE); - -typedef struct SDL_SysWMinfo SDL_SysWMinfo; - - -/** - * Get driver-specific information about a window. - * - * You must include SDL_syswm.h for the declaration of SDL_SysWMinfo. - * - * \param window the window about which information is being requested - * \param info an SDL_SysWMinfo structure filled in with window information - * \param version the version of info being requested, should be - * SDL_SYSWM_CURRENT_VERSION - * \returns 0 on success or a negative error code on failure; call - * SDL_GetError() for more information. - * - * \since This function is available since SDL 3.0.0. - */ -extern DECLSPEC int SDLCALL SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *info, Uint32 version); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include - -#endif /* SDL_syswm_h_ */ diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index 3f79502556f020..a03e0a5b1f52cc 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -934,6 +934,52 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window); /** * Get the properties associated with a window. * + * The following properties are provided by SDL: + * + * On Android: + * "SDL.window.android.window" - the ANativeWindow associated with the window + * "SDL.window.android.surface" - the EGLSurface associated with the window + * + * On iOS: + * "SDL.window.uikit.window" - the (__unsafe_unretained) UIWindow associated with the window + * "SDL.window.uikit.metal_view_tag" - the NSInteger tag assocated with metal views on the window + * + * On KMS/DRM: + * "SDL.window.kmsdrm.dev_index" - the device index associated with the window (e.g. the X in /dev/dri/cardX) + * "SDL.window.kmsdrm.drm_fd" - the DRM FD associated with the window + * "SDL.window.kmsdrm.gbm_dev" - the GBM device associated with the window + * + * On macOS: + * "SDL.window.cocoa.window" - the (__unsafe_unretained) NSWindow associated with the window + * "SDL.window.cocoa.metal_view_tag" - the NSInteger tag assocated with metal views on the window + * + * On Vivante: + * "SDL.window.vivante.display" - the EGLNativeDisplayType associated with the window + * "SDL.window.vivante.window" - the EGLNativeWindowType associated with the window + * "SDL.window.vivante.surface" - the EGLSurface associated with the window + * + * On UWP: + * "SDL.window.winrt.window" - the IInspectable CoreWindow associated with the window + * + * On Windows: + * "SDL.window.win32.hwnd" - the HWND associated with the window + * "SDL.window.win32.hdc" - the HDC associated with the window + * "SDL.window.win32.instance" - the HINSTANCE associated with the window + * + * On Wayland: + * "SDL.window.wayland.display" - the wl_display associated with the window + * "SDL.window.wayland.surface" - the wl_surface associated with the window + * "SDL.window.wayland.egl_window" - the wl_egl_window associated with the window + * "SDL.window.wayland.xdg_surface" - the xdg_surface associated with the window + * "SDL.window.wayland.xdg_toplevel" - the xdg_toplevel role associated with the window + * "SDL.window.wayland.xdg_popup" - the xdg_popup role associated with the window + * "SDL.window.wayland.xdg_positioner" - the xdg_positioner associated with the window, in popup mode + * + * On X11: + * "SDL.window.x11.display" - the X11 Display associated with the window + * "SDL.window.x11.screen" - the screen number associated with the window + * "SDL.window.x11.window" - the X11 Window associated with the window + * * \param window the window to query * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. diff --git a/include/build_config/SDL_build_config.h.cmake b/include/build_config/SDL_build_config.h.cmake index 091751fb3fb0fa..b776251f81e424 100644 --- a/include/build_config/SDL_build_config.h.cmake +++ b/include/build_config/SDL_build_config.h.cmake @@ -415,62 +415,6 @@ #cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@ #cmakedefine SDL_VIDEO_DRIVER_QNX @SDL_VIDEO_DRIVER_QNX@ -#ifdef SDL_VIDEO_DRIVER_ANDROID -#define SDL_ENABLE_SYSWM_ANDROID -#else -#define SDL_DISABLE_SYSWM_ANDROID -#endif -#ifdef SDL_VIDEO_DRIVER_COCOA -#define SDL_ENABLE_SYSWM_COCOA -#else -#define SDL_DISABLE_SYSWM_COCOA -#endif -#ifdef SDL_VIDEO_DRIVER_HAIKU -#define SDL_ENABLE_SYSWM_HAIKU -#else -#define SDL_DISABLE_SYSWM_HAIKU -#endif -#ifdef SDL_VIDEO_DRIVER_KMSDRM -#define SDL_ENABLE_SYSWM_KMSDRM -#else -#define SDL_DISABLE_SYSWM_KMSDRM -#endif -#ifdef SDL_VIDEO_DRIVER_RISCOS -#define SDL_ENABLE_SYSWM_RISCOS -#else -#define SDL_DISABLE_SYSWM_RISCOS -#endif -#ifdef SDL_VIDEO_DRIVER_UIKIT -#define SDL_ENABLE_SYSWM_UIKIT -#else -#define SDL_DISABLE_SYSWM_UIKIT -#endif -#ifdef SDL_VIDEO_DRIVER_VIVANTE -#define SDL_ENABLE_SYSWM_VIVANTE -#else -#define SDL_DISABLE_SYSWM_VIVANTE -#endif -#ifdef SDL_VIDEO_DRIVER_WAYLAND -#define SDL_ENABLE_SYSWM_WAYLAND -#else -#define SDL_DISABLE_SYSWM_WAYLAND -#endif -#ifdef SDL_VIDEO_DRIVER_WINDOWS -#define SDL_ENABLE_SYSWM_WINDOWS -#else -#define SDL_DISABLE_SYSWM_WINDOWS -#endif -#ifdef SDL_VIDEO_DRIVER_WINRT -#define SDL_ENABLE_SYSWM_WINRT -#else -#define SDL_DISABLE_SYSWM_WINRT -#endif -#ifdef SDL_VIDEO_DRIVER_X11 -#define SDL_ENABLE_SYSWM_X11 -#else -#define SDL_DISABLE_SYSWM_X11 -#endif - #cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ #cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ #cmakedefine SDL_VIDEO_RENDER_D3D12 @SDL_VIDEO_RENDER_D3D12@ diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c index 5e1f82834944c6..82329b0f0b057a 100644 --- a/src/core/SDL_core_unsupported.c +++ b/src/core/SDL_core_unsupported.c @@ -20,6 +20,14 @@ */ #include "SDL_internal.h" +#ifndef SDL_VIDEO_DRIVER_X11 + +DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata) +{ +} + +#endif + #ifndef __LINUX__ DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index bbf3f453764aad..efbbb1275f06f9 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -29,7 +29,6 @@ #ifdef SDL_VIDEO_DRIVER_X11 #include "../../video/x11/SDL_x11video.h" #endif -#include #define FCITX_DBUS_SERVICE "org.freedesktop.portal.Fcitx" @@ -412,7 +411,6 @@ SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) { SDL_Window *focused_win = NULL; - SDL_SysWMinfo info; int x = 0, y = 0; SDL_Rect *cursor = &fcitx_client.cursor_rect; @@ -427,17 +425,18 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) SDL_GetWindowPosition(focused_win, &x, &y); - if (SDL_GetWindowWMInfo(focused_win, &info, SDL_SYSWM_CURRENT_VERSION) == 0) { -#ifdef SDL_ENABLE_SYSWM_X11 - if (info.subsystem == SDL_SYSWM_X11) { - Display *x_disp = info.info.x11.display; - int x_screen = info.info.x11.screen; - Window x_win = info.info.x11.window; - Window unused; +#ifdef SDL_VIDEO_DRIVER_X11 + { + SDL_PropertiesID props = SDL_GetWindowProperties(focused_win); + Display *x_disp = (Display *)SDL_GetProperty(props, "SDL.window.x11.display"); + int x_screen = (int)SDL_GetProperty(props, "SDL.window.x11.screen"); + Window x_win = (Window)SDL_GetProperty(props, "SDL.window.x11.window"); + Window unused; + if (x_disp && x_win) { X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); } -#endif } +#endif if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) { /* move to bottom left */ diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 237c300fcd91e3..8634bd6b7eef01 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -32,7 +32,6 @@ #ifdef SDL_VIDEO_DRIVER_X11 #include "../../video/x11/SDL_x11video.h" #endif -#include #include #include @@ -689,7 +688,6 @@ SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state) void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) { SDL_Window *focused_win; - SDL_SysWMinfo info; int x = 0, y = 0; SDL_DBusContext *dbus; @@ -704,18 +702,18 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) SDL_GetWindowPosition(focused_win, &x, &y); - if (SDL_GetWindowWMInfo(focused_win, &info, SDL_SYSWM_CURRENT_VERSION) == 0) { -#ifdef SDL_ENABLE_SYSWM_X11 - if (info.subsystem == SDL_SYSWM_X11) { - Display *x_disp = info.info.x11.display; - int x_screen = info.info.x11.screen; - Window x_win = info.info.x11.window; - Window unused; +#ifdef SDL_VIDEO_DRIVER_X11 + { + SDL_PropertiesID props = SDL_GetWindowProperties(focused_win); + Display *x_disp = (Display *)SDL_GetProperty(props, "SDL.window.x11.display"); + int x_screen = (int)SDL_GetProperty(props, "SDL.window.x11.screen"); + Window x_win = (Window)SDL_GetProperty(props, "SDL.window.x11.window"); + if (x_disp && x_win) { X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); } -#endif } +#endif x += ibus_cursor_rect.x; y += ibus_cursor_rect.y; diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 23cf60432e3011..833a98072d898b 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -37,7 +37,6 @@ /* These headers have system specific definitions, so aren't included above */ -#include #include /* This is the version of the dynamic API. This doesn't match the SDL version diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index dc1899f9bea3df..720591affbeb22 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -360,7 +360,6 @@ SDL3_0.0.0 { SDL_GetWindowSizeInPixels; SDL_GetWindowSurface; SDL_GetWindowTitle; - SDL_GetWindowWMInfo; SDL_GetYUVConversionMode; SDL_GetYUVConversionModeForResolution; SDL_HapticClose; @@ -922,6 +921,7 @@ SDL3_0.0.0 { SDL_AllocateEventMemory; SDL_GetDisplayProperties; SDL_SetPropertyWithCleanup; + SDL_SetX11EventHook; # extra symbols go here (don't modify this line) local: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 35fff15baf8061..a6c5440ca33d16 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -384,7 +384,6 @@ #define SDL_GetWindowSizeInPixels SDL_GetWindowSizeInPixels_REAL #define SDL_GetWindowSurface SDL_GetWindowSurface_REAL #define SDL_GetWindowTitle SDL_GetWindowTitle_REAL -#define SDL_GetWindowWMInfo SDL_GetWindowWMInfo_REAL #define SDL_GetYUVConversionMode SDL_GetYUVConversionMode_REAL #define SDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution_REAL #define SDL_HapticClose SDL_HapticClose_REAL @@ -947,3 +946,4 @@ #define SDL_AllocateEventMemory SDL_AllocateEventMemory_REAL #define SDL_GetDisplayProperties SDL_GetDisplayProperties_REAL #define SDL_SetPropertyWithCleanup SDL_SetPropertyWithCleanup_REAL +#define SDL_SetX11EventHook SDL_SetX11EventHook_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 9f28f674482870..3348c67a8f44d7 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -443,7 +443,6 @@ SDL_DYNAPI_PROC(int,SDL_GetWindowSize,(SDL_Window *a, int *b, int *c),(a,b,c),re SDL_DYNAPI_PROC(int,SDL_GetWindowSizeInPixels,(SDL_Window *a, int *b, int *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_GetWindowSurface,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetWindowTitle,(SDL_Window *a),(a),return) -SDL_DYNAPI_PROC(int,SDL_GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionMode,(void),(),return) SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionModeForResolution,(int a, int b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_HapticClose,(SDL_Haptic *a),(a),) @@ -980,3 +979,4 @@ SDL_DYNAPI_PROC(size_t,SDL_RWvprintf,(SDL_RWops *a, const char *b, va_list c),(a SDL_DYNAPI_PROC(void*,SDL_AllocateEventMemory,(size_t a),(a),return) SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetDisplayProperties,(SDL_DisplayID a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return) +SDL_DYNAPI_PROC(void,SDL_SetX11EventHook,(SDL_X11EventHook a, void *b),(a,b),) diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 337180dbc7947e..f79f46970e3e2c 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -33,7 +33,6 @@ #include "../sensor/SDL_sensor_c.h" #endif #include "../video/SDL_sysvideo.h" -#include #undef SDL_PRIs64 #if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__) @@ -194,7 +193,6 @@ static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, co * - 0: (default) no logging * - 1: logging of most events * - 2: as above, plus mouse and finger motion - * - 3: as above, plus SDL_SysWMEvents */ static int SDL_EventLoggingVerbosity = 0; @@ -218,11 +216,6 @@ static void SDL_LogEvent(const SDL_Event *event) return; } - /* window manager events are even more spammy, and don't provide much useful info. */ - if ((SDL_EventLoggingVerbosity < 3) && (event->type == SDL_EVENT_SYSWM)) { - return; - } - /* this is to make (void)SDL_snprintf() calls cleaner. */ #define uint unsigned int @@ -321,11 +314,6 @@ static void SDL_LogEvent(const SDL_Event *event) SDL_WINDOWEVENT_CASE(SDL_EVENT_WINDOW_DESTROYED); #undef SDL_WINDOWEVENT_CASE - SDL_EVENT_CASE(SDL_EVENT_SYSWM) - /* !!! FIXME: we don't delve further at the moment. */ - (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u)", (uint)event->syswm.timestamp); - break; - #define PRINT_KEY_EVENT(event) \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \ (uint)event->key.timestamp, (uint)event->key.windowID, \ @@ -644,7 +632,6 @@ int SDL_StartEventLoop(void) /* Process most event types */ SDL_SetEventEnabled(SDL_EVENT_TEXT_INPUT, SDL_FALSE); SDL_SetEventEnabled(SDL_EVENT_TEXT_EDITING, SDL_FALSE); - SDL_SetEventEnabled(SDL_EVENT_SYSWM, SDL_FALSE); #if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */ SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_FALSE); SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, SDL_FALSE); @@ -1405,27 +1392,6 @@ int SDL_SendAppEvent(SDL_EventType eventType) return posted; } -int SDL_SendSysWMEvent(SDL_SysWMmsg *message) -{ - int posted; - - posted = 0; - if (SDL_EventEnabled(SDL_EVENT_SYSWM)) { - SDL_Event event; - SDL_memset(&event, 0, sizeof(event)); - event.type = SDL_EVENT_SYSWM; - event.common.timestamp = 0; - event.syswm.msg = (SDL_SysWMmsg *)SDL_AllocateEventMemory(sizeof(*message)); - if (!event.syswm.msg) { - return 0; - } - SDL_copyp(event.syswm.msg, message); - posted = (SDL_PushEvent(&event) > 0); - } - /* Update internal event state */ - return posted; -} - int SDL_SendKeymapChangedEvent(void) { return SDL_SendAppEvent(SDL_EVENT_KEYMAP_CHANGED); diff --git a/src/events/SDL_events_c.h b/src/events/SDL_events_c.h index 44c3eb8d110f49..8c6310cd25b27a 100644 --- a/src/events/SDL_events_c.h +++ b/src/events/SDL_events_c.h @@ -41,7 +41,6 @@ extern void SDL_StopEventLoop(void); extern void SDL_QuitInterrupt(void); extern int SDL_SendAppEvent(SDL_EventType eventType); -extern int SDL_SendSysWMEvent(SDL_SysWMmsg *message); extern int SDL_SendKeymapChangedEvent(void); extern int SDL_SendLocaleChangedEvent(void); extern int SDL_SendSystemThemeChangedEvent(void); diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index abfe5d5e06d417..9324087eb8bb03 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -28,8 +28,6 @@ #include "../SDL_d3dmath.h" #include "../../video/windows/SDL_windowsvideo.h" -#include - #ifdef SDL_VIDEO_RENDER_D3D #define D3D_DEBUG_INFO #include @@ -1542,7 +1540,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; D3D_RenderData *data; - SDL_SysWMinfo windowinfo; HRESULT result; D3DPRESENT_PARAMETERS pparams; IDirect3DSwapChain9 *chain; @@ -1552,12 +1549,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_DisplayID displayID; const SDL_DisplayMode *fullscreen_mode = NULL; - if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || - windowinfo.subsystem != SDL_SYSWM_WINDOWS) { - SDL_SetError("Couldn't get window handle"); - return NULL; - } - renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); if (renderer == NULL) { SDL_OutOfMemory(); @@ -1611,7 +1602,7 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) } SDL_zero(pparams); - pparams.hDeviceWindow = windowinfo.info.win.window; + pparams.hDeviceWindow = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd"); pparams.BackBufferWidth = w; pparams.BackBufferHeight = h; pparams.BackBufferCount = 1; diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index f15344ad204fa5..ef11c7de3b074f 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -30,8 +30,6 @@ #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" -#include - #include #include "SDL_shaders_d3d11.h" @@ -827,18 +825,11 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) #endif } else { #if defined(__WIN32__) || defined(__WINGDK__) - SDL_SysWMinfo windowinfo; - - if (SDL_GetWindowWMInfo(renderer->window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || - windowinfo.subsystem != SDL_SYSWM_WINDOWS) { - SDL_SetError("Couldn't get window handle"); - result = E_FAIL; - goto done; - } + HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), "SDL.window.win32.hwnd"); result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, (IUnknown *)data->d3dDevice, - windowinfo.info.win.window, + hwnd, &swapChainDesc, NULL, NULL, /* Allow on all displays. */ @@ -848,7 +839,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) goto done; } - IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES); + IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, hwnd, DXGI_MWA_NO_WINDOW_CHANGES); #else SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to"); goto done; diff --git a/src/render/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp index 0bf3609cf56480..4ecd41908771da 100644 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ b/src/render/direct3d11/SDL_render_winrt.cpp @@ -39,35 +39,14 @@ using namespace Windows::Graphics::Display; #include -#include - #include "SDL_render_winrt.h" extern "C" void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer) { - SDL_Window *sdlWindow = renderer->window; - if (renderer->window == NULL) { - return NULL; - } - - SDL_SysWMinfo sdlWindowInfo; - if (SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo, SDL_SYSWM_CURRENT_VERSION) < 0 || - sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) { - SDL_SetError("Couldn't get window handle"); - return NULL; - } - - if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) { - return NULL; - } - - if (!sdlWindowInfo.info.winrt.window) { - return NULL; - } - + IInspectable *window = (IInspectable *)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), "SDL.window.winrt.window"); ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL; - if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) { + if (!window || FAILED(window->QueryInterface(&coreWindow))) { return NULL; } diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 7c0fa525aa0212..2fd1f00d10b5d7 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -32,8 +32,6 @@ #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" -#include - #if defined(__XBOXONE__) || defined(__XBOXSERIES__) #include "SDL_render_d3d12_xbox.h" #ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT @@ -1153,7 +1151,6 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; IDXGISwapChain1 *swapChain = NULL; HRESULT result = S_OK; - SDL_SysWMinfo windowinfo; /* Create a swap chain using the same adapter as the existing Direct3D device. */ DXGI_SWAP_CHAIN_DESC1 swapChainDesc; @@ -1175,16 +1172,11 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT | /* To support SetMaximumFrameLatency */ DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */ - if (SDL_GetWindowWMInfo(renderer->window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || - windowinfo.subsystem != SDL_SYSWM_WINDOWS) { - SDL_SetError("Couldn't get window handle"); - result = E_FAIL; - goto done; - } + HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), "SDL.window.win32.hwnd"); result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd, (IUnknown *)data->commandQueue, - windowinfo.info.win.window, + hwnd, &swapChainDesc, NULL, NULL, /* Allow on all displays. */ @@ -1194,7 +1186,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) goto done; } - D3D_CALL(data->dxgiFactory, MakeWindowAssociation, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES); + D3D_CALL(data->dxgiFactory, MakeWindowAssociation, hwnd, DXGI_MWA_NO_WINDOW_CHANGES); result = D3D_CALL(swapChain, QueryInterface, D3D_GUID(SDL_IID_IDXGISwapChain4), (void **)&data->swapChain); if (FAILED(result)) { diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index 3f038f272d3f32..606b17f17dc246 100644 --- a/src/render/metal/SDL_render_metal.m +++ b/src/render/metal/SDL_render_metal.m @@ -35,7 +35,6 @@ #ifdef SDL_VIDEO_DRIVER_UIKIT #import #endif -#include /* Regenerate these with build-metal-shaders.sh */ #ifdef __MACOS__ @@ -160,20 +159,16 @@ @interface METAL_TextureData : NSObject @implementation METAL_TextureData @end -static int IsMetalAvailable(const SDL_SysWMinfo *syswm) +static SDL_bool IsMetalAvailable() { - if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) { - return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment."); - } - - // this checks a weak symbol. #if (defined(__MACOS__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100)) + // this checks a weak symbol. if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower. - return SDL_SetError("Metal framework not available on this system"); + SDL_SetError("Metal framework not available on this system"); + return SDL_FALSE; } #endif - - return 0; + return SDL_TRUE; } static const MTLBlendOperation invalidBlendOperation = (MTLBlendOperation)0xFFFFFFFF; @@ -1630,29 +1625,31 @@ static int METAL_SetVSync(SDL_Renderer *renderer, const int vsync) static SDL_MetalView GetWindowView(SDL_Window *window) { - SDL_SysWMinfo info; - - if (SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) == 0) { -#ifdef SDL_ENABLE_SYSWM_COCOA - if (info.subsystem == SDL_SYSWM_COCOA) { - NSView *view = info.info.cocoa.window.contentView; - if (view.subviews.count > 0) { - view = view.subviews[0]; - if (view.tag == SDL_METALVIEW_TAG) { - return (SDL_MetalView)CFBridgingRetain(view); - } - } - } -#endif -#ifdef SDL_ENABLE_SYSWM_UIKIT - if (info.subsystem == SDL_SYSWM_UIKIT) { - UIView *view = info.info.uikit.window.rootViewController.view; - if (view.tag == SDL_METALVIEW_TAG) { +#ifdef SDL_VIDEO_DRIVER_COCOA + NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window"); + NSInteger tag = (NSInteger)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.metal_view_tag"); + if (nswindow) { + NSView *view = nswindow.contentView; + if (view.subviews.count > 0) { + view = view.subviews[0]; + if (view.tag == tag) { return (SDL_MetalView)CFBridgingRetain(view); } } + } #endif + +#ifdef SDL_VIDEO_DRIVER_UIKIT + UIWindow *uiwindow = (__bridge UIWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.uikit.window"); + NSInteger tag = (NSInteger)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.uikit.metal_view_tag"); + if (uiwindow) { + UIView *view = uiwindow.rootViewController.view; + if (view.tag == tag) { + return (SDL_MetalView)CFBridgingRetain(view); + } } +#endif + return nil; } @@ -1664,7 +1661,6 @@ static SDL_MetalView GetWindowView(SDL_Window *window) id mtldevice = nil; SDL_MetalView view = NULL; CAMetalLayer *layer = nil; - SDL_SysWMinfo syswm; NSError *err = nil; dispatch_data_t mtllibdata; char *constantdata; @@ -1740,11 +1736,7 @@ static SDL_MetalView GetWindowView(SDL_Window *window) 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ }; - if (SDL_GetWindowWMInfo(window, &syswm, SDL_SYSWM_CURRENT_VERSION) < 0) { - return NULL; - } - - if (IsMetalAvailable(&syswm) == -1) { + if (!IsMetalAvailable()) { return NULL; } diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 3db2d85b1fedf6..fe3e5fd52a4de0 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -151,9 +151,6 @@ struct SDL_VideoDisplay SDL_DisplayData *driverdata; }; -/* Forward declaration */ -struct SDL_SysWMinfo; - /* Video device flags */ typedef enum { @@ -267,9 +264,6 @@ struct SDL_VideoDevice */ SDL_ShapeDriver shape_driver; - /* Get some platform dependent window information */ - int (*GetWindowWMInfo)(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); - /* * * */ /* * OpenGL support diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index a4f771b74c3146..bb983b902a01d3 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -32,8 +32,6 @@ #include "../events/SDL_events_c.h" #include "../timer/SDL_timer_c.h" -#include - #ifdef SDL_VIDEO_OPENGL #include #endif /* SDL_VIDEO_OPENGL */ @@ -4671,33 +4669,6 @@ void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) } #endif -int SDL_GetWindowWMInfo(SDL_Window *window, struct SDL_SysWMinfo *info, Uint32 version) -{ - CHECK_WINDOW_MAGIC(window, -1); - - if (info == NULL) { - return SDL_InvalidParamError("info"); - } - - /* Set the version in the structure to the minimum of our version and the application expected version */ - version = SDL_min(version, SDL_SYSWM_CURRENT_VERSION); - - if (version == 1) { - SDL_memset(info, 0, SDL_SYSWM_INFO_SIZE_V1); - } else { - return SDL_SetError("Unknown info version"); - } - - info->subsystem = SDL_SYSWM_UNKNOWN; - info->version = version; - - if (_this->GetWindowWMInfo) { - return (_this->GetWindowWMInfo(_this, window, info)); - } else { - return 0; - } -} - void SDL_StartTextInput(void) { SDL_Window *window; @@ -4827,20 +4798,6 @@ int SDL_GetMessageBoxCount(void) #include "vita/SDL_vitamessagebox.h" #endif -#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) || defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT) || defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_HAIKU) || defined(SDL_VIDEO_DRIVER_RISCOS) -static SDL_bool SDL_IsMessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) -{ - SDL_SysWMinfo info; - SDL_Window *window = messageboxdata->window; - - if (window == NULL || SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) < 0) { - return SDL_TRUE; - } else { - return info.subsystem == (Uint32)drivertype; - } -} -#endif - int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int dummybutton; @@ -4894,56 +4851,48 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) #endif #if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) && WIN_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_WINRT if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINRT) && WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_COCOA if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) && Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_UIKIT if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) && UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_WAYLAND if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) && Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_X11 if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) && X11_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_HAIKU if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) && HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } #endif #ifdef SDL_VIDEO_DRIVER_RISCOS if (retval == -1 && - SDL_IsMessageboxValidForDriver(messageboxdata, SDL_SYSWM_RISCOS) && RISCOS_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index ede5b1c9631c01..96cc2d7edb869b 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -117,7 +117,6 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->MinimizeWindow = Android_MinimizeWindow; device->SetWindowResizable = Android_SetWindowResizable; device->DestroyWindow = Android_DestroyWindow; - device->GetWindowWMInfo = Android_GetWindowWMInfo; device->free = Android_DeleteDevice; diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index 85f044f48bdfc4..1d1577cfff09f2 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -35,7 +35,6 @@ #include "SDL_androidvulkan.h" -#include int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 491765529f36c5..1ef9cd518269d5 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -31,7 +31,6 @@ #include "SDL_androidvideo.h" #include "SDL_androidwindow.h" -#include /* Currently only one window */ SDL_Window *Android_Window = NULL; @@ -68,12 +67,12 @@ int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) } data->native_window = Android_JNI_GetNativeWindow(); - if (!data->native_window) { SDL_free(data); retval = SDL_SetError("Could not fetch native window"); goto endfunction; } + SDL_SetProperty(SDL_GetWindowProperties(window), "SDL.window.android.window", data->native_window); /* Do not create EGLSurface for Vulkan window since it will then make the window incompatible with vkCreateAndroidSurfaceKHR */ @@ -88,6 +87,7 @@ int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) goto endfunction; } } + SDL_SetProperty(SDL_GetWindowProperties(window), "SDL.window.android.surface", data->egl_surface); #endif window->driverdata = data; @@ -194,18 +194,4 @@ void Android_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_UnlockMutex(Android_ActivityMutex); } -int Android_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - SDL_WindowData *data = window->driverdata; - - info->subsystem = SDL_SYSWM_ANDROID; - info->info.android.window = data->native_window; - -#ifdef SDL_VIDEO_OPENGL_EGL - info->info.android.surface = data->egl_surface; -#endif - - return 0; -} - #endif /* SDL_VIDEO_DRIVER_ANDROID */ diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index 439156119d0305..ea81d3bc802d95 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -33,7 +33,6 @@ extern void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); extern void Android_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int Android_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); extern SDL_Window *Android_Window; struct SDL_WindowData diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index 46d11251e8c0b8..08a5c0d4728723 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -30,8 +30,6 @@ #if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) -#include - static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) { /* Update the drawable size when SDL receives a size changed event for diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 3b6092b00cb29e..bd2fdf8148bb8e 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -115,7 +115,6 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice *device) device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab; device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab; device->DestroyWindow = Cocoa_DestroyWindow; - device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; device->SetWindowHitTest = Cocoa_SetWindowHitTest; device->AcceptDragAndDrop = Cocoa_AcceptDragAndDrop; device->FlashWindow = Cocoa_FlashWindow; diff --git a/src/video/cocoa/SDL_cocoavulkan.m b/src/video/cocoa/SDL_cocoavulkan.m index d5d3cb88da69ff..a018db5a82805a 100644 --- a/src/video/cocoa/SDL_cocoavulkan.m +++ b/src/video/cocoa/SDL_cocoavulkan.m @@ -33,8 +33,6 @@ #include "SDL_cocoametalview.h" #include "SDL_cocoavulkan.h" -#include - #include const char *defaultPaths[] = { diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 1408784b28e1d0..8e4158cf6724a9 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -29,6 +29,8 @@ #include "../SDL_egl_c.h" #endif +#define SDL_METALVIEW_TAG 255 + @class SDL_CocoaWindowData; typedef enum @@ -165,7 +167,6 @@ extern SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Windo extern void Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); extern void Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); extern void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int Cocoa_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); extern int Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 970e8e1f17cdd2..c7e004b2202173 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -41,7 +41,6 @@ #include "SDL_cocoaopengl.h" #include "SDL_cocoaopengles.h" -#include /* #define DEBUG_COCOAWINDOW */ @@ -1863,6 +1862,10 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow */ [nswindow setOneShot:NO]; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.cocoa.window", (__bridge void *)data.nswindow); + SDL_SetProperty(props, "SDL.window.cocoa.metal_view_tag", SDL_METALVIEW_TAG); + /* All done! */ window->driverdata = (SDL_WindowData *)CFBridgingRetain(data); return 0; @@ -2580,17 +2583,6 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } } -int Cocoa_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - @autoreleasepool { - NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)window->driverdata).nswindow; - - info->subsystem = SDL_SYSWM_COCOA; - info->info.cocoa.window = nswindow; - return 0; - } -} - SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window) { @autoreleasepool { diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h index e053f483c3b727..4cd1582cd9b7c9 100644 --- a/src/video/haiku/SDL_BWin.h +++ b/src/video/haiku/SDL_BWin.h @@ -29,8 +29,6 @@ extern "C" { #include "SDL_internal.h" #include "SDL_bframebuffer.h" -#include - #ifdef __cplusplus } #endif diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 14e3ef2fd6ed89..86b8037d531b0d 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -91,7 +91,6 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void) device->SetWindowMouseGrab = HAIKU_SetWindowMouseGrab; device->SetWindowMinimumSize = HAIKU_SetWindowMinimumSize; device->DestroyWindow = HAIKU_DestroyWindow; - device->GetWindowWMInfo = HAIKU_GetWindowWMInfo; device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer; diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index 2d309e6aa07e15..f69bec1f67e033 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -26,8 +26,6 @@ #include "SDL_BWin.h" #include -#include - /* Define a path to window's BWIN data */ #ifdef __cplusplus extern "C" { @@ -211,13 +209,6 @@ void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window * window) { window->driverdata = NULL; } -int HAIKU_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info) -{ - info->subsystem = SDL_SYSWM_HAIKU; - return 0; -} - - #ifdef __cplusplus } #endif diff --git a/src/video/haiku/SDL_bwindow.h b/src/video/haiku/SDL_bwindow.h index 0597acbcedd209..400fa9467a5a43 100644 --- a/src/video/haiku/SDL_bwindow.h +++ b/src/video/haiku/SDL_bwindow.h @@ -41,6 +41,5 @@ extern void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, extern void HAIKU_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen); extern void HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); extern void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int HAIKU_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); #endif diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 5312a584e93d5c..9f721e5984611f 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -35,8 +35,6 @@ #include "../../core/openbsd/SDL_wscons.h" #endif -#include - /* KMS/DRM declarations */ #include "SDL_kmsdrmdyn.h" #include "SDL_kmsdrmevents.h" @@ -295,7 +293,6 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) device->MinimizeWindow = KMSDRM_MinimizeWindow; device->RestoreWindow = KMSDRM_RestoreWindow; device->DestroyWindow = KMSDRM_DestroyWindow; - device->GetWindowWMInfo = KMSDRM_GetWindowWMInfo; device->GL_LoadLibrary = KMSDRM_GLES_LoadLibrary; device->GL_GetProcAddress = KMSDRM_GLES_GetProcAddress; @@ -1437,6 +1434,11 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) windata->viddata = viddata; window->driverdata = windata; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.kmsdrm.dev_index", viddata->devindex); + SDL_SetProperty(props, "SDL.window.kmsdrm.drm_fd", viddata->drm_fd); + SDL_SetProperty(props, "SDL.window.kmsdrm.gbm_dev", viddata->gbm_dev); + if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */ /* Maybe you didn't ask for an OPENGL window, but that's what you will get. @@ -1595,19 +1597,4 @@ void KMSDRM_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) { } -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -int KMSDRM_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info) -{ - SDL_VideoData *viddata = _this->driverdata; - - info->subsystem = SDL_SYSWM_KMSDRM; - info->info.kmsdrm.dev_index = viddata->devindex; - info->info.kmsdrm.drm_fd = viddata->drm_fd; - info->info.kmsdrm.gbm_dev = viddata->gbm_dev; - - return 0; -} - #endif /* SDL_VIDEO_DRIVER_KMSDRM */ diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index 24e03fb9b0cc19..d488fc84aed897 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -135,9 +135,6 @@ void KMSDRM_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); void KMSDRM_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* Window manager function */ -int KMSDRM_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); - /* OpenGL/OpenGL ES functions */ int KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); SDL_FunctionPointer KMSDRM_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 20b6516e35410b..038bd2db92dcb9 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -34,8 +34,6 @@ #include "SDL_kmsdrmdyn.h" #include "SDL_kmsdrmvulkan.h" -#include - #include #ifdef __OpenBSD__ diff --git a/src/video/ngage/SDL_ngagewindow.h b/src/video/ngage/SDL_ngagewindow.h index 1418ab7c3a7143..811142dd7e632c 100644 --- a/src/video/ngage/SDL_ngagewindow.h +++ b/src/video/ngage/SDL_ngagewindow.h @@ -24,8 +24,6 @@ #include "../SDL_sysvideo.h" -#include - #include "SDL_ngagevideo.h" typedef struct @@ -34,10 +32,7 @@ typedef struct } NGAGE_Window; -extern int -NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window); - -extern void -NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); #endif /* SDL_ngagewindow */ diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index 7b47fa38b4d0bc..5cf0d7288d55db 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -28,8 +28,6 @@ #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" -#include - /* PSP declarations */ #include "SDL_pspvideo.h" #include "SDL_pspevents_c.h" diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 40519a9236457c..3d5d0888b43836 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -35,8 +35,6 @@ #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" -#include - #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" #endif diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index dd57ce839e5735..a2df367f994dff 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -79,7 +79,6 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) device->CreateSDLWindow = RISCOS_CreateWindow; device->DestroyWindow = RISCOS_DestroyWindow; - device->GetWindowWMInfo = RISCOS_GetWindowWMInfo; device->CreateWindowFramebuffer = RISCOS_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = RISCOS_UpdateWindowFramebuffer; diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c index 80a0e94f7f43ee..b0a3a207a50e3e 100644 --- a/src/video/riscos/SDL_riscoswindow.c +++ b/src/video/riscos/SDL_riscoswindow.c @@ -25,8 +25,6 @@ #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" -#include - #include "SDL_riscosvideo.h" #include "SDL_riscoswindow.h" @@ -61,10 +59,4 @@ void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) window->driverdata = NULL; } -int RISCOS_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info) -{ - info->subsystem = SDL_SYSWM_RISCOS; - return 0; -} - #endif /* SDL_VIDEO_DRIVER_RISCOS */ diff --git a/src/video/riscos/SDL_riscoswindow.h b/src/video/riscos/SDL_riscoswindow.h index e05466481a3be2..6899a3d2a80166 100644 --- a/src/video/riscos/SDL_riscoswindow.h +++ b/src/video/riscos/SDL_riscoswindow.h @@ -34,6 +34,5 @@ struct SDL_WindowData extern int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int RISCOS_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); #endif /* SDL_riscoswindow_h_ */ diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m index c5317ebd900c04..accda70361c36a 100644 --- a/src/video/uikit/SDL_uikitmetalview.m +++ b/src/video/uikit/SDL_uikitmetalview.m @@ -35,8 +35,6 @@ #import "SDL_uikitwindow.h" #import "SDL_uikitmetalview.h" -#include - @implementation SDL_uikitmetalview /* Returns a Metal-compatible layer. */ diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 0e1919bde3ebd7..0c37b33421f42c 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -94,7 +94,6 @@ static void UIKit_DeleteDevice(SDL_VideoDevice *device) device->SetWindowFullscreen = UIKit_SetWindowFullscreen; device->SetWindowMouseGrab = UIKit_SetWindowMouseGrab; device->DestroyWindow = UIKit_DestroyWindow; - device->GetWindowWMInfo = UIKit_GetWindowWMInfo; device->GetDisplayUsableBounds = UIKit_GetDisplayUsableBounds; device->GetWindowSizeInPixels = UIKit_GetWindowSizeInPixels; diff --git a/src/video/uikit/SDL_uikitvulkan.m b/src/video/uikit/SDL_uikitvulkan.m index b6191ae0b3c089..a8816a4eb62fea 100644 --- a/src/video/uikit/SDL_uikitvulkan.m +++ b/src/video/uikit/SDL_uikitvulkan.m @@ -34,8 +34,6 @@ #include "SDL_uikitvulkan.h" #include "SDL_uikitmetalview.h" -#include - #include const char *defaultPaths[] = { diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h index ba89566293a42e..64ba38c13d2ed0 100644 --- a/src/video/uikit/SDL_uikitwindow.h +++ b/src/video/uikit/SDL_uikitwindow.h @@ -37,10 +37,11 @@ extern void UIKit_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, extern void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window); extern void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); -extern int UIKit_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); extern NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window); +#define SDL_METALVIEW_TAG 255 + @class UIWindow; @interface SDL_UIKitWindowData : NSObject diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index ed8c6dcd1722c1..407e6edf4d5188 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -34,8 +34,6 @@ #include "SDL_uikitview.h" #include "SDL_uikitopenglview.h" -#include - #include @implementation SDL_UIKitWindowData @@ -86,13 +84,13 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_uikitview *view; - + #if TARGET_OS_XR CGRect frame = UIKit_ComputeViewFrame(window); #else CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen); #endif - + int width = (int)frame.size.width; int height = (int)frame.size.height; @@ -155,6 +153,10 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow * hierarchy. */ [view setSDLWindow:window]; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.uikit.window", (__bridge void *)data.uiwindow); + SDL_SetProperty(props, "SDL.window.uikit.metal_view_tag", SDL_METALVIEW_TAG); + return 0; } @@ -385,26 +387,6 @@ void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int } } -int UIKit_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - @autoreleasepool { - SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata; - - info->subsystem = SDL_SYSWM_UIKIT; - info->info.uikit.window = data.uiwindow; - -#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) - if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) { - SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view; - info->info.uikit.framebuffer = glview.drawableFramebuffer; - info->info.uikit.colorbuffer = glview.drawableRenderbuffer; - info->info.uikit.resolveFramebuffer = glview.msaaResolveFramebuffer; - } -#endif - return 0; - } -} - #if !TARGET_OS_TV NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window) diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index 97a0a254e8ed12..3b59a3662a7d51 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -28,8 +28,6 @@ #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" -#include - /* VITA declarations */ #include #include "SDL_vitavideo.h" diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index 06c69dd3485140..69eef0a349966c 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -26,8 +26,6 @@ #include "../SDL_sysvideo.h" #include "../../events/SDL_events_c.h" -#include - #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" #endif @@ -81,7 +79,6 @@ static SDL_VideoDevice *VIVANTE_Create() device->ShowWindow = VIVANTE_ShowWindow; device->HideWindow = VIVANTE_HideWindow; device->DestroyWindow = VIVANTE_DestroyWindow; - device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo; #ifdef SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary; @@ -258,6 +255,9 @@ int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Setup driver data for this window */ window->driverdata = data; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.vivante.display", displaydata->native_display); + #ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h); #else @@ -266,6 +266,7 @@ int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) if (!data->native_window) { return SDL_SetError("VIVANTE: Can't create native window"); } + SDL_SetProperty(props, "SDL.window.vivante.window", data->native_window); #ifdef SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { @@ -276,6 +277,7 @@ int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) } else { data->egl_surface = EGL_NO_SURFACE; } + SDL_SetProperty(props, "SDL.window.vivante.surface", data->egl_surface); #endif /* Window has been successfully created */ @@ -347,20 +349,6 @@ void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_SetKeyboardFocus(NULL); } -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -int VIVANTE_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info) -{ - SDL_WindowData *data = window->driverdata; - SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay()); - - info->subsystem = SDL_SYSWM_VIVANTE; - info->info.vivante.display = displaydata->native_display; - info->info.vivante.window = data->native_window; - return 0; -} - /*****************************************************************************/ /* SDL event functions */ /*****************************************************************************/ diff --git a/src/video/vivante/SDL_vivantevideo.h b/src/video/vivante/SDL_vivantevideo.h index 290851fc8b43e0..ca9a62ed6ca571 100644 --- a/src/video/vivante/SDL_vivantevideo.h +++ b/src/video/vivante/SDL_vivantevideo.h @@ -80,9 +80,6 @@ void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); void VIVANTE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -/* Window manager function */ -int VIVANTE_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); - /* Event functions */ void VIVANTE_PumpEvents(SDL_VideoDevice *_this); diff --git a/src/video/vivante/SDL_vivantevulkan.c b/src/video/vivante/SDL_vivantevulkan.c index 9244bf0b256bfa..a8fcb0ff658959 100644 --- a/src/video/vivante/SDL_vivantevulkan.c +++ b/src/video/vivante/SDL_vivantevulkan.c @@ -33,7 +33,6 @@ #include "SDL_vivantevideo.h" #include "SDL_vivantevulkan.h" -#include int VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index d4a30bdf05465c..96d7f390fd393b 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -174,7 +174,6 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) device->VideoInit = Wayland_VideoInit; device->VideoQuit = Wayland_VideoQuit; device->GetDisplayBounds = Wayland_GetDisplayBounds; - device->GetWindowWMInfo = Wayland_GetWindowWMInfo; device->SuspendScreenSaver = Wayland_SuspendScreenSaver; device->PumpEvents = Wayland_PumpEvents; diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index 99a9cd13e40fc4..75cef415f1dd42 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -36,8 +36,6 @@ #include "../SDL_vulkan_internal.h" #include "SDL_waylandvulkan.h" -#include - #ifdef __OpenBSD__ #define DEFAULT_VULKAN "libvulkan.so" #else diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index f0927f08cff18c..c5267d3f586bff 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1301,37 +1301,6 @@ static void SetKeyboardFocus(SDL_Window *window) SDL_SetKeyboardFocus(window); } -int Wayland_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - SDL_VideoData *viddata = _this->driverdata; - SDL_WindowData *data = window->driverdata; - - info->subsystem = SDL_SYSWM_WAYLAND; - info->info.wl.display = data->waylandData->display; - info->info.wl.surface = data->surface; - info->info.wl.egl_window = data->egl_window; - -#ifdef HAVE_LIBDECOR_H - if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame != NULL) { - info->info.wl.xdg_surface = libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); - info->info.wl.xdg_toplevel = libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); - } - } else -#endif - if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { - SDL_bool popup = (data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP); - info->info.wl.xdg_surface = data->shell_surface.xdg.surface; - info->info.wl.xdg_toplevel = popup ? NULL : data->shell_surface.xdg.roleobj.toplevel; - if (popup) { - info->info.wl.xdg_popup = data->shell_surface.xdg.roleobj.popup.popup; - info->info.wl.xdg_positioner = data->shell_surface.xdg.roleobj.popup.positioner; - } - } - - return 0; -} - int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { return 0; /* just succeed, the real work is done elsewhere. */ @@ -1380,6 +1349,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_VideoData *c = _this->driverdata; SDL_WindowData *data = window->driverdata; + SDL_PropertiesID props = SDL_GetWindowProperties(props); /* If this is a child window, the parent *must* be in the final shown state, * meaning that it has received a configure event, followed by a frame callback. @@ -1427,13 +1397,17 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) } else { libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, data->app_id); libdecor_frame_map(data->shell_surface.libdecor.frame); + + SDL_SetProperty(props, "SDL.window.wayland.xdg_surface", libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); + SDL_SetProperty(props, "SDL.window.wayland.xdg_toplevel", libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); } } else #endif - if ((data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL || data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) && c->shell.xdg) { + if ((data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL || data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) && c->shell.xdg) { data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface); xdg_surface_set_user_data(data->shell_surface.xdg.surface, data); xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data); + SDL_SetProperty(SDL_GetWindowProperties(window), "SDL.window.wayland.xdg_surface", data->shell_surface.xdg.surface); if (data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { SDL_Window *parent = window->parent; @@ -1485,10 +1459,14 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) SetKeyboardFocus(window); } } + + SDL_SetProperty(props, "SDL.window.wayland.xdg_popup", data->shell_surface.xdg.roleobj.popup.popup); + SDL_SetProperty(props, "SDL.window.wayland.xdg_positioner", data->shell_surface.xdg.roleobj.popup.positioner); } else { data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface); xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, data->app_id); xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data); + SDL_SetProperty(props, "SDL.window.wayland.xdg_toplevel", data->shell_surface.xdg.roleobj.toplevel); } } @@ -1624,12 +1602,17 @@ static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) xdg_positioner_destroy(popupdata->shell_surface.xdg.roleobj.popup.positioner); popupdata->shell_surface.xdg.roleobj.popup.popup = NULL; popupdata->shell_surface.xdg.roleobj.popup.positioner = NULL; + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.wayland.xdg_popup", NULL); + SDL_SetProperty(props, "SDL.window.wayland.xdg_positioner", NULL); } void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_VideoData *data = _this->driverdata; SDL_WindowData *wind = window->driverdata; + SDL_PropertiesID props = SDL_GetWindowProperties(window); wind->surface_status = WAYLAND_SURFACE_STATUS_HIDDEN; @@ -1649,19 +1632,24 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) if (wind->shell_surface.libdecor.frame) { libdecor_frame_unref(wind->shell_surface.libdecor.frame); wind->shell_surface.libdecor.frame = NULL; + + SDL_SetProperty(props, "SDL.window.wayland.xdg_surface", NULL); + SDL_SetProperty(props, "SDL.window.wayland.xdg_toplevel", NULL); } } else #endif - if (data->shell.xdg) { + if (data->shell.xdg) { if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) { Wayland_ReleasePopup(_this, window); } else if (wind->shell_surface.xdg.roleobj.toplevel) { xdg_toplevel_destroy(wind->shell_surface.xdg.roleobj.toplevel); wind->shell_surface.xdg.roleobj.toplevel = NULL; + SDL_SetProperty(props, "SDL.window.wayland.xdg_toplevel", NULL); } if (wind->shell_surface.xdg.surface) { xdg_surface_destroy(wind->shell_surface.xdg.surface); wind->shell_surface.xdg.surface = NULL; + SDL_SetProperty(props, "SDL.window.wayland.xdg_surface", NULL); } } @@ -2109,6 +2097,11 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) } } /* All other cases will be WAYLAND_SURFACE_UNKNOWN */ + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.wayland.display", data->waylandData->display); + SDL_SetProperty(props, "SDL.window.wayland.surface", data->surface); + SDL_SetProperty(props, "SDL.window.wayland.egl_window", data->egl_window); + return 0; } diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index a7d9ba4e9e6796..d2105706d76262 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -27,8 +27,6 @@ #include "../SDL_sysvideo.h" #include "../../events/SDL_touch_c.h" -#include - #include "SDL_waylandvideo.h" struct SDL_WaylandInput; @@ -151,7 +149,6 @@ extern void Wayland_ShowWindowSystemMenu(SDL_Window *window, int x, int y); extern void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int Wayland_SuspendScreenSaver(SDL_VideoDevice *_this); -extern int Wayland_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info); extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern int Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 41d94182225f57..57abda4fb1bcec 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -29,8 +29,6 @@ #include "../../events/SDL_touch_c.h" #include "../../events/scancodes_windows.h" -#include - /* Dropfile support */ #include @@ -715,19 +713,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_WindowData *data; LRESULT returnCode = -1; - /* Send a SDL_EVENT_SYSWM if the application wants them */ - if (SDL_EventEnabled(SDL_EVENT_SYSWM)) { - SDL_SysWMmsg wmmsg; - - wmmsg.version = SDL_SYSWM_CURRENT_VERSION; - wmmsg.subsystem = SDL_SYSWM_WINDOWS; - wmmsg.msg.win.hwnd = hwnd; - wmmsg.msg.win.msg = msg; - wmmsg.msg.win.wParam = wParam; - wmmsg.msg.win.lParam = lParam; - SDL_SendSysWMEvent(&wmmsg); - } - /* Get the window data for the window */ data = WIN_GetWindowDataFromHWND(hwnd); #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) @@ -1809,7 +1794,9 @@ int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) return 0; } if (g_WindowsMessageHook) { - g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam); + if (!g_WindowsMessageHook(g_WindowsMessageHookData, &msg)) { + return 1; + } } /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */ TranslateMessage(&msg); @@ -1845,7 +1832,9 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (g_WindowsMessageHook) { - g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam); + if (!g_WindowsMessageHook(g_WindowsMessageHookData, &msg)) { + continue; + } } #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index b0d7122b506687..0bd8fd5b663efd 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -201,7 +201,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab; #endif device->DestroyWindow = WIN_DestroyWindow; - device->GetWindowWMInfo = WIN_GetWindowWMInfo; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer; diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index e2e2a39a60c603..f52892d0f0a2aa 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -35,8 +35,6 @@ #include "SDL_windowsvulkan.h" -#include - int WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 159a7abd8ca961..95927b74dc785c 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -38,8 +38,6 @@ /* Dropfile support */ #include -#include - /* Dark mode support */ #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 @@ -440,6 +438,11 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd data->initializing = SDL_FALSE; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.win32.hwnd", data->hwnd); + SDL_SetProperty(props, "SDL.window.win32.hdc", data->hdc); + SDL_SetProperty(props, "SDL.window.win32.instance", data->hinstance); + /* All done! */ return 0; } @@ -1250,18 +1253,6 @@ void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) CleanupWindowData(_this, window); } -int WIN_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - const SDL_WindowData *data = (const SDL_WindowData *)window->driverdata; - - info->subsystem = SDL_SYSWM_WINDOWS; - info->info.win.window = data->hwnd; - info->info.win.hdc = data->hdc; - info->info.win.hinstance = data->hinstance; - - return 0; -} - /* * Creates a HelperWindow used for DirectInput. */ diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 527fee78d17fd5..5b2c0260c0ea0c 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -100,7 +100,6 @@ extern void WIN_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); extern void WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); extern void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int WIN_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); extern void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_UpdateClipCursor(SDL_Window *window); extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index b98f67526f132b..5b742024ea4313 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -67,8 +67,6 @@ extern "C" { #include "SDL_winrtmouse_c.h" #include "SDL_winrtvideo_cpp.h" -#include - /* Initialization/Query functions */ static int WINRT_VideoInit(SDL_VideoDevice *_this); static int WINRT_InitModes(SDL_VideoDevice *_this); @@ -80,7 +78,6 @@ static int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window); static void WINRT_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); static void WINRT_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen); static void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -static int WINRT_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info); /* Misc functions */ static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(SDL_VideoDevice *_this); @@ -133,7 +130,6 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) device->DestroyWindow = WINRT_DestroyWindow; device->SetDisplayMode = WINRT_SetDisplayMode; device->PumpEvents = WINRT_PumpEvents; - device->GetWindowWMInfo = WINRT_GetWindowWMInfo; device->SuspendScreenSaver = WINRT_SuspendScreenSaver; #if NTDDI_VERSION >= NTDDI_WIN10 @@ -612,6 +608,7 @@ int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) data->appView = ApplicationView::GetForCurrentView(); #endif } + SDL_SetProperty(SDL_GetWindowProperties(window), "SDL.window.winrt.window", reinterpret_cast(data->coreWindow.Get()); /* Make note of the requested window flags, before they start getting changed. */ const Uint32 requestedFlags = window->flags; @@ -779,15 +776,6 @@ void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } } -int WINRT_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - SDL_WindowData *data = window->driverdata; - - info->subsystem = SDL_SYSWM_WINRT; - info->info.winrt.window = reinterpret_cast(data->coreWindow.Get()); - return 0; -} - static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(SDL_VideoDevice *_this) { /* Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests */ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 9c7afcf445208f..8c5c96d3a06957 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -40,8 +40,6 @@ #include "../../core/linux/SDL_system_theme.h" #include "../../SDL_utils_c.h" -#include - #include /*#define DEBUG_XEVENTS*/ @@ -324,27 +322,25 @@ static char *X11_URIToLocal(char *uri) return file; } +/* An X11 event hook */ +static SDL_X11EventHook g_X11EventHook = NULL; +static void *g_X11EventHookData = NULL; + +void SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata) +{ + g_X11EventHook = callback; + g_X11EventHookData = userdata; +} + #ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS static void X11_HandleGenericEvent(SDL_VideoData *videodata, XEvent *xev) { /* event is a union, so cookie == &event, but this is type safe. */ XGenericEventCookie *cookie = &xev->xcookie; if (X11_XGetEventData(videodata->display, cookie)) { - X11_HandleXinput2Event(videodata, cookie); - - /* Send a SDL_EVENT_SYSWM if the application wants them. - * Since event data is only available until XFreeEventData is called, - * the *only* way for an application to access it is to register an event filter/watcher - * and do all the processing on the SDL_EVENT_SYSWM inside the callback. */ - if (SDL_EventEnabled(SDL_EVENT_SYSWM)) { - SDL_SysWMmsg wmmsg; - - wmmsg.version = SDL_SYSWM_CURRENT_VERSION; - wmmsg.subsystem = SDL_SYSWM_X11; - wmmsg.msg.x11.event = *xev; - SDL_SendSysWMEvent(&wmmsg); + if (!g_X11EventHook || g_X11EventHook(g_X11EventHookData, xev)) { + X11_HandleXinput2Event(videodata, cookie); } - X11_XFreeEventData(videodata->display, cookie); } } @@ -870,22 +866,19 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } #endif + /* Calling the event hook for generic events happens in X11_HandleGenericEvent(), where the event data is available */ + if (g_X11EventHook) { + if (!g_X11EventHook(g_X11EventHookData, xevent)) { + return; + } + } + #ifdef SDL_VIDEO_DRIVER_X11_XRANDR if (videodata->xrandr_event_base && (xevent->type == (videodata->xrandr_event_base + RRNotify))) { X11_HandleXRandREvent(_this, xevent); } #endif - /* Send a SDL_EVENT_SYSWM if the application wants them */ - if (SDL_EventEnabled(SDL_EVENT_SYSWM)) { - SDL_SysWMmsg wmmsg; - - wmmsg.version = SDL_SYSWM_CURRENT_VERSION; - wmmsg.subsystem = SDL_SYSWM_X11; - wmmsg.msg.x11.event = *xevent; - SDL_SendSysWMEvent(&wmmsg); - } - #if 0 printf("type = %d display = %d window = %d\n", xevent->type, xevent->xany.display, xevent->xany.window); diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index ac1340c79322ce..1e164e84cccd78 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -207,7 +207,6 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer; - device->GetWindowWMInfo = X11_GetWindowWMInfo; device->SetWindowHitTest = X11_SetWindowHitTest; device->AcceptDragAndDrop = X11_AcceptDragAndDrop; device->FlashWindow = X11_FlashWindow; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index a1c5bb82198ad0..844a6c45dd0e4f 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -39,8 +39,6 @@ #include "SDL_x11opengles.h" #endif -#include - #define _NET_WM_STATE_REMOVE 0l #define _NET_WM_STATE_ADD 1l @@ -382,6 +380,12 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w, /* All done! */ window->driverdata = data; + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetProperty(props, "SDL.window.x11.display", data->videodata->display); + SDL_SetProperty(props, "SDL.window.x11.screen", displaydata->screen); + SDL_SetProperty(props, "SDL.window.x11.window", data->xwindow); + return 0; } @@ -1848,23 +1852,6 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) window->driverdata = NULL; } -int X11_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, SDL_SysWMinfo *info) -{ - SDL_WindowData *data = window->driverdata; - SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); - - if (data == NULL) { - /* This sometimes happens in SDL_IBus_UpdateTextRect() while creating the window */ - return SDL_SetError("Window not initialized"); - } - - info->subsystem = SDL_SYSWM_X11; - info->info.x11.display = data->videodata->display; - info->info.x11.screen = displaydata->screen; - info->info.x11.window = data->xwindow; - return 0; -} - int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { return 0; /* just succeed, the real work is done elsewhere. */ diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index b9d6ab0d0ee32f..03b8b8cdee4525 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -111,7 +111,6 @@ extern void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, extern void X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); extern void X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); extern void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int X11_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info); extern int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); extern int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); diff --git a/test/testautomation.c b/test/testautomation.c index 7cdd6be9337a93..f2bb2e8ebcdf37 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -42,7 +42,6 @@ static SDLTest_TestSuiteReference *testSuites[] = { &sdltestTestSuite, &stdlibTestSuite, &surfaceTestSuite, - &syswmTestSuite, &timerTestSuite, &videoTestSuite, &subsystemsTestSuite, /* run last, not interfere with other test enviroment */ diff --git a/test/testautomation_suites.h b/test/testautomation_suites.h index 9a562620a2d0ea..143ec15369a4a0 100644 --- a/test/testautomation_suites.h +++ b/test/testautomation_suites.h @@ -30,7 +30,6 @@ extern SDLTest_TestSuiteReference sdltestTestSuite; extern SDLTest_TestSuiteReference stdlibTestSuite; extern SDLTest_TestSuiteReference subsystemsTestSuite; extern SDLTest_TestSuiteReference surfaceTestSuite; -extern SDLTest_TestSuiteReference syswmTestSuite; extern SDLTest_TestSuiteReference timerTestSuite; extern SDLTest_TestSuiteReference videoTestSuite; diff --git a/test/testautomation_syswm.c b/test/testautomation_syswm.c deleted file mode 100644 index e05f114915823b..00000000000000 --- a/test/testautomation_syswm.c +++ /dev/null @@ -1,60 +0,0 @@ -/** - * SysWM test suite - */ - -/* Avoid inclusion of e.g. X11 headers when these are not installed */ -#include - -#include -#include -#include -#include "testautomation_suites.h" - -/* Test case functions */ - -/** - * Call to SDL_GetWindowWMInfo - */ -static int syswm_getWindowWMInfo(void *arg) -{ - int result; - SDL_Window *window; - SDL_SysWMinfo info; - - window = SDL_CreateWindow("", 0, 0, SDL_WINDOW_HIDDEN); - SDLTest_AssertPass("Call to SDL_CreateWindow()"); - SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); - if (window == NULL) { - return TEST_ABORTED; - } - - /* Make call */ - result = SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION); - SDLTest_AssertPass("Call to SDL_GetWindowWMInfo()"); - SDLTest_Log((result == 0) ? "Got window information" : "Couldn't get window information"); - - SDL_DestroyWindow(window); - SDLTest_AssertPass("Call to SDL_DestroyWindow()"); - - return TEST_COMPLETED; -} - -/* ================= Test References ================== */ - -/* SysWM test cases */ -static const SDLTest_TestCaseReference syswmTest1 = { - (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED -}; - -/* Sequence of SysWM test cases */ -static const SDLTest_TestCaseReference *syswmTests[] = { - &syswmTest1, NULL -}; - -/* SysWM test suite (global) */ -SDLTest_TestSuiteReference syswmTestSuite = { - "SysWM", - NULL, - syswmTests, - NULL -};