Skip to content

Commit

Permalink
SDL_syswm.h has been removed and replaced with window properties
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 8, 2023
1 parent aea6e6d commit fd4a2cc
Show file tree
Hide file tree
Showing 82 changed files with 277 additions and 1,069 deletions.
1 change: 0 additions & 1 deletion VisualC-GDK/SDL/SDL.vcxproj
Expand Up @@ -345,7 +345,6 @@
<ClInclude Include="..\..\include\SDL3\SDL_stdinc.h" />
<ClInclude Include="..\..\include\SDL3\SDL_surface.h" />
<ClInclude Include="..\..\include\SDL3\SDL_system.h" />
<ClInclude Include="..\..\include\SDL3\SDL_syswm.h" />
<ClInclude Include="..\..\include\SDL3\SDL_test.h" />
<ClInclude Include="..\..\include\SDL3\SDL_test_assert.h" />
<ClInclude Include="..\..\include\SDL3\SDL_test_common.h" />
Expand Down
3 changes: 0 additions & 3 deletions VisualC-GDK/SDL/SDL.vcxproj.filters
Expand Up @@ -348,9 +348,6 @@
<ClInclude Include="..\..\include\SDL3\SDL_system.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL3\SDL_syswm.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL3\SDL_test.h">
<Filter>API Headers</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion VisualC-WinRT/SDL-UWP.vcxproj
Expand Up @@ -83,7 +83,6 @@
<ClInclude Include="..\include\SDL3\SDL_stdinc.h" />
<ClInclude Include="..\include\SDL3\SDL_surface.h" />
<ClInclude Include="..\include\SDL3\SDL_system.h" />
<ClInclude Include="..\include\SDL3\SDL_syswm.h" />
<ClInclude Include="..\include\SDL3\SDL_thread.h" />
<ClInclude Include="..\include\SDL3\SDL_timer.h" />
<ClInclude Include="..\include\SDL3\SDL_touch.h" />
Expand Down
3 changes: 0 additions & 3 deletions VisualC-WinRT/SDL-UWP.vcxproj.filters
Expand Up @@ -147,9 +147,6 @@
<ClInclude Include="..\include\SDL3\SDL_system.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\SDL3\SDL_syswm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\SDL3\SDL_thread.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion VisualC/SDL/SDL.vcxproj
Expand Up @@ -296,7 +296,6 @@
<ClInclude Include="..\..\include\SDL3\SDL_stdinc.h" />
<ClInclude Include="..\..\include\SDL3\SDL_surface.h" />
<ClInclude Include="..\..\include\SDL3\SDL_system.h" />
<ClInclude Include="..\..\include\SDL3\SDL_syswm.h" />
<ClInclude Include="..\..\include\SDL3\SDL_test.h" />
<ClInclude Include="..\..\include\SDL3\SDL_test_assert.h" />
<ClInclude Include="..\..\include\SDL3\SDL_test_common.h" />
Expand Down
3 changes: 0 additions & 3 deletions VisualC/SDL/SDL.vcxproj.filters
Expand Up @@ -342,9 +342,6 @@
<ClInclude Include="..\..\include\SDL3\SDL_system.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL3\SDL_syswm.h">
<Filter>API Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL3\SDL_test.h">
<Filter>API Headers</Filter>
</ClInclude>
Expand Down
3 changes: 1 addition & 2 deletions VisualC/tests/testautomation/testautomation.vcxproj
Expand Up @@ -218,7 +218,6 @@
<ClCompile Include="..\..\..\test\testautomation_sdltest.c" />
<ClCompile Include="..\..\..\test\testautomation_stdlib.c" />
<ClCompile Include="..\..\..\test\testautomation_surface.c" />
<ClCompile Include="..\..\..\test\testautomation_syswm.c" />
<ClCompile Include="..\..\..\test\testautomation_timer.c" />
<ClCompile Include="..\..\..\test\testautomation_video.c" />
<ClCompile Include="..\..\..\test\testautomation_subsystems.c" />
Expand All @@ -229,4 +228,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
4 changes: 0 additions & 4 deletions Xcode/SDL/SDL.xcodeproj/project.pbxproj
Expand Up @@ -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, ); }; };
Expand Down Expand Up @@ -939,7 +938,6 @@
F3F7D8BC2933074A00816151 /* SDL_error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_error.h; path = SDL3/SDL_error.h; sourceTree = "<group>"; };
F3F7D8BD2933074A00816151 /* SDL_opengles2_gl2ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_opengles2_gl2ext.h; path = SDL3/SDL_opengles2_gl2ext.h; sourceTree = "<group>"; };
F3F7D8BE2933074A00816151 /* SDL_endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_endian.h; path = SDL3/SDL_endian.h; sourceTree = "<group>"; };
F3F7D8BF2933074A00816151 /* SDL_syswm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_syswm.h; path = SDL3/SDL_syswm.h; sourceTree = "<group>"; };
F3F7D8C02933074A00816151 /* SDL_opengl_glext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_opengl_glext.h; path = SDL3/SDL_opengl_glext.h; sourceTree = "<group>"; };
F3F7D8C12933074B00816151 /* SDL_scancode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scancode.h; path = SDL3/SDL_scancode.h; sourceTree = "<group>"; };
F3F7D8C22933074B00816151 /* SDL_sensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_sensor.h; path = SDL3/SDL_sensor.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
20 changes: 0 additions & 20 deletions docs/README-ios.md
Expand Up @@ -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
==============================================================================

Expand Down
26 changes: 25 additions & 1 deletion docs/README-migration.md
Expand Up @@ -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:
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/README-winrt.md
Expand Up @@ -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:
Expand Down
28 changes: 3 additions & 25 deletions include/SDL3/SDL_events.h
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion include/SDL3/SDL_hints.h
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions include/SDL3/SDL_oldnames.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
48 changes: 40 additions & 8 deletions include/SDL3/SDL_system.h
Expand Up @@ -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`
*
Expand Down Expand Up @@ -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__

/**
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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__

/**
Expand Down Expand Up @@ -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__

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fd4a2cc

Please sign in to comment.