Updated SDL_syswm.h for SDL 3.0

* The header is no longer dependent on SDL build configuration
* The structures are versioned separately from the rest of SDL
* SDL_GetWindowWMInfo() now returns a standard result code and is passed the version expected by the application
* Updated WhatsNew.txt and docs/README-migration.md with the first API changes in SDL 3.0
This commit is contained in:
Sam Lantinga
2022-11-23 13:33:48 -08:00
parent 53ca1f7702
commit b0840eb32e
57 changed files with 349 additions and 1411 deletions

View File

@@ -40,86 +40,38 @@
* 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_EventState().
*
* As of SDL 3.0, this file no longer includes the platform specific headers
* and types. You should include the headers you need and define one or more
* of the following for the subsystems you're working with:
*
* SDL_ENABLE_SYSWM_ANDROID
* SDL_ENABLE_SYSWM_COCOA
* SDL_ENABLE_SYSWM_KMSDRM
* SDL_ENABLE_SYSWM_UIKIT
* SDL_ENABLE_SYSWM_VIVANTE
* SDL_ENABLE_SYSWM_WAYLAND
* SDL_ENABLE_SYSWM_WINDOWS
* SDL_ENABLE_SYSWM_WINRT
* SDL_ENABLE_SYSWM_X11
*/
struct SDL_SysWMinfo;
#if !defined(SDL_PROTOTYPES_ONLY)
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX /* don't define min() and max(). */
#define NOMINMAX
#endif
#include <windows.h>
#endif
#if defined(SDL_VIDEO_DRIVER_WINRT)
#include <Inspectable.h>
#endif
/* This is the structure for custom window manager events */
#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(__APPLE__) && defined(__MACH__)
/* conflicts with Quickdraw.h */
#define Cursor X11Cursor
#endif
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#if defined(__APPLE__) && defined(__MACH__)
/* matches the re-define above */
#undef Cursor
#endif
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
#if defined(SDL_VIDEO_DRIVER_COCOA)
#ifdef __OBJC__
@class NSWindow;
#else
typedef struct _NSWindow NSWindow;
#endif
#endif
#if defined(SDL_VIDEO_DRIVER_UIKIT)
#ifdef __OBJC__
#include <UIKit/UIKit.h>
#else
typedef struct _UIWindow UIWindow;
typedef struct _UIViewController UIViewController;
#endif
typedef Uint32 GLuint;
#endif
#if defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)
#define SDL_METALVIEW_TAG 255
#endif
#if defined(SDL_VIDEO_DRIVER_ANDROID)
typedef struct ANativeWindow ANativeWindow;
typedef void *EGLSurface;
#endif
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
#include "SDL_egl.h"
#endif
#endif /* SDL_PROTOTYPES_ONLY */
#if defined(SDL_VIDEO_DRIVER_KMSDRM)
struct gbm_device;
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* This is the current version of structures in this file */
#define SDL_SYSWM_CURRENT_VERSION 1
#define SDL_SYSWM_INFO_SIZE_V1 (16 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)))
#define SDL_SYSWM_CURRENT_INFO_SIZE SDL_SYSWM_INFO_SIZE_V1
/* This is the tag associated with a Metal view so you can find it */
#define SDL_METALVIEW_TAG 255
#if !defined(SDL_PROTOTYPES_ONLY)
/**
* These are the various supported windowing subsystems
@@ -127,17 +79,17 @@ extern "C" {
typedef enum
{
SDL_SYSWM_UNKNOWN,
SDL_SYSWM_WINDOWS,
SDL_SYSWM_X11,
SDL_SYSWM_COCOA,
SDL_SYSWM_UIKIT,
SDL_SYSWM_WAYLAND,
SDL_SYSWM_WINRT,
SDL_SYSWM_ANDROID,
SDL_SYSWM_VIVANTE,
SDL_SYSWM_COCOA,
SDL_SYSWM_HAIKU,
SDL_SYSWM_KMSDRM,
SDL_SYSWM_RISCOS
SDL_SYSWM_RISCOS,
SDL_SYSWM_UIKIT,
SDL_SYSWM_VIVANTE,
SDL_SYSWM_WAYLAND,
SDL_SYSWM_WINDOWS,
SDL_SYSWM_WINRT,
SDL_SYSWM_X11
} SDL_SYSWM_TYPE;
/**
@@ -145,11 +97,14 @@ typedef enum
*/
struct SDL_SysWMmsg
{
SDL_version version;
SDL_SYSWM_TYPE subsystem;
Uint32 version;
Uint32 subsystem; /**< SDL_SYSWM_TYPE */
Uint32 padding[(2 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)) - 2 * sizeof(Uint32)) / sizeof(Uint32)];
union
{
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
#if defined(SDL_ENABLE_SYSWM_WINDOWS)
struct {
HWND hwnd; /**< The window for the message */
UINT msg; /**< The type of message */
@@ -157,34 +112,10 @@ struct SDL_SysWMmsg
LPARAM lParam; /**< LONG message parameter */
} win;
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(SDL_ENABLE_SYSWM_X11)
struct {
XEvent event;
} x11;
#endif
#if defined(SDL_VIDEO_DRIVER_COCOA)
struct
{
/* Latest version of Xcode clang complains about empty structs in C v. C++:
error: empty struct has size 0 in C, size 1 in C++
*/
int dummy;
/* No Cocoa window events yet */
} cocoa;
#endif
#if defined(SDL_VIDEO_DRIVER_UIKIT)
struct
{
int dummy;
/* No UIKit window events yet */
} uikit;
#endif
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
struct
{
int dummy;
/* No Vivante window events yet */
} vivante;
#endif
/* Can't have an empty union */
int dummy;
@@ -199,11 +130,14 @@ struct SDL_SysWMmsg
*/
struct SDL_SysWMinfo
{
SDL_version version;
SDL_SYSWM_TYPE subsystem;
Uint32 version;
Uint32 subsystem; /**< SDL_SYSWM_TYPE */
Uint32 padding[(2 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)) - 2 * sizeof(Uint32)) / sizeof(Uint32)];
union
{
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
#if defined(SDL_ENABLE_SYSWM_WINDOWS)
struct
{
HWND window; /**< The window handle */
@@ -211,20 +145,21 @@ struct SDL_SysWMinfo
HINSTANCE hinstance; /**< The instance handle */
} win;
#endif
#if defined(SDL_VIDEO_DRIVER_WINRT)
#if defined(SDL_ENABLE_SYSWM_WINRT)
struct
{
IInspectable * window; /**< The WinRT CoreWindow */
} winrt;
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(SDL_ENABLE_SYSWM_X11)
struct
{
Display *display; /**< The X11 display */
int screen; /**< The X11 screen */
Window window; /**< The X11 window */
} x11;
#endif
#if defined(SDL_VIDEO_DRIVER_COCOA)
#if defined(SDL_ENABLE_SYSWM_COCOA)
struct
{
#if defined(__OBJC__) && defined(__has_feature)
@@ -238,7 +173,7 @@ struct SDL_SysWMinfo
#endif
} cocoa;
#endif
#if defined(SDL_VIDEO_DRIVER_UIKIT)
#if defined(SDL_ENABLE_SYSWM_UIKIT)
struct
{
#if defined(__OBJC__) && defined(__has_feature)
@@ -255,12 +190,11 @@ struct SDL_SysWMinfo
GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
} uikit;
#endif
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
#if defined(SDL_ENABLE_SYSWM_WAYLAND)
struct
{
struct wl_display *display; /**< Wayland display */
struct wl_surface *surface; /**< Wayland surface */
void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */
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 */
@@ -269,7 +203,7 @@ struct SDL_SysWMinfo
} wl;
#endif
#if defined(SDL_VIDEO_DRIVER_ANDROID)
#if defined(SDL_ENABLE_SYSWM_ANDROID)
struct
{
ANativeWindow *window;
@@ -277,7 +211,7 @@ struct SDL_SysWMinfo
} android;
#endif
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
#if defined(SDL_ENABLE_SYSWM_VIVANTE)
struct
{
EGLNativeDisplayType display;
@@ -285,7 +219,7 @@ struct SDL_SysWMinfo
} vivante;
#endif
#if defined(SDL_VIDEO_DRIVER_KMSDRM)
#if defined(SDL_ENABLE_SYSWM_KMSDRM)
struct
{
int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */
@@ -294,11 +228,12 @@ struct SDL_SysWMinfo
} kmsdrm;
#endif
/* Make sure this union is always 64 bytes (8 64-bit pointers). */
/* Be careful not to overflow this if you add a new target! */
Uint8 dummy[64];
/* 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);
#endif /* SDL_PROTOTYPES_ONLY */
@@ -310,20 +245,15 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
*
* You must include SDL_syswm.h for the declaration of SDL_SysWMinfo.
*
* The caller must initialize the `info` structure's version by using
* `SDL_VERSION(&info.version)`, and then this function will fill in the rest
* of the structure with information about the given window.
*
* \param window the window about which information is being requested
* \param info an SDL_SysWMinfo structure filled in with window information
* \returns SDL_TRUE if the function is implemented and the `version` member
* of the `info` struct is valid, or SDL_FALSE if the information
* could not be retrieved; call SDL_GetError() for more 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 SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
SDL_SysWMinfo * info);
extern DECLSPEC int SDLCALL SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *info, Uint32 version);
/* Ends C function definitions when using C++ */