SDL  2.0
SDL_syswm.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /**
23  * \file SDL_syswm.h
24  *
25  * Include file for SDL custom system window manager hooks.
26  */
27 
28 #ifndef SDL_syswm_h_
29 #define SDL_syswm_h_
30 
31 #include "SDL_stdinc.h"
32 #include "SDL_error.h"
33 #include "SDL_video.h"
34 #include "SDL_version.h"
35 
36 /**
37  * \brief SDL_syswm.h
38  *
39  * Your application has access to a special type of event ::SDL_SYSWMEVENT,
40  * which contains window-manager specific information and arrives whenever
41  * an unhandled window event occurs. This event is ignored by default, but
42  * you can enable it with SDL_EventState().
43  */
44 struct SDL_SysWMinfo;
45 
46 #if !defined(SDL_PROTOTYPES_ONLY)
47 
48 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
49 #ifndef WIN32_LEAN_AND_MEAN
50 #define WIN32_LEAN_AND_MEAN
51 #endif
52 #include <windows.h>
53 #endif
54 
55 #if defined(SDL_VIDEO_DRIVER_WINRT)
56 #include <Inspectable.h>
57 #endif
58 
59 /* This is the structure for custom window manager events */
60 #if defined(SDL_VIDEO_DRIVER_X11)
61 #if defined(__APPLE__) && defined(__MACH__)
62 /* conflicts with Quickdraw.h */
63 #define Cursor X11Cursor
64 #endif
65 
66 #include <X11/Xlib.h>
67 #include <X11/Xatom.h>
68 
69 #if defined(__APPLE__) && defined(__MACH__)
70 /* matches the re-define above */
71 #undef Cursor
72 #endif
73 
74 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
75 
76 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
77 #include <directfb.h>
78 #endif
79 
80 #if defined(SDL_VIDEO_DRIVER_COCOA)
81 #ifdef __OBJC__
82 @class NSWindow;
83 #else
84 typedef struct _NSWindow NSWindow;
85 #endif
86 #endif
87 
88 #if defined(SDL_VIDEO_DRIVER_UIKIT)
89 #ifdef __OBJC__
90 #include <UIKit/UIKit.h>
91 #else
92 typedef struct _UIWindow UIWindow;
93 typedef struct _UIViewController UIViewController;
94 #endif
95 typedef Uint32 GLuint;
96 #endif
97 
98 #if defined(SDL_VIDEO_DRIVER_ANDROID)
99 typedef struct ANativeWindow ANativeWindow;
100 typedef void *EGLSurface;
101 #endif
102 
103 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
104 #include "SDL_egl.h"
105 #endif
106 #endif /* SDL_PROTOTYPES_ONLY */
107 
108 
109 #include "begin_code.h"
110 /* Set up for C function definitions, even when using C++ */
111 #ifdef __cplusplus
112 extern "C" {
113 #endif
114 
115 #if !defined(SDL_PROTOTYPES_ONLY)
116 /**
117  * These are the various supported windowing subsystems
118  */
119 typedef enum
120 {
128  SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
134 
135 /**
136  * The custom event structure.
137  */
139 {
142  union
143  {
144 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
145  struct {
146  HWND hwnd; /**< The window for the message */
147  UINT msg; /**< The type of message */
148  WPARAM wParam; /**< WORD message parameter */
149  LPARAM lParam; /**< LONG message parameter */
150  } win;
151 #endif
152 #if defined(SDL_VIDEO_DRIVER_X11)
153  struct {
154  XEvent event;
155  } x11;
156 #endif
157 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
158  struct {
159  DFBEvent event;
160  } dfb;
161 #endif
162 #if defined(SDL_VIDEO_DRIVER_COCOA)
163  struct
164  {
165  /* Latest version of Xcode clang complains about empty structs in C v. C++:
166  error: empty struct has size 0 in C, size 1 in C++
167  */
168  int dummy;
169  /* No Cocoa window events yet */
170  } cocoa;
171 #endif
172 #if defined(SDL_VIDEO_DRIVER_UIKIT)
173  struct
174  {
175  int dummy;
176  /* No UIKit window events yet */
177  } uikit;
178 #endif
179 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
180  struct
181  {
182  int dummy;
183  /* No Vivante window events yet */
184  } vivante;
185 #endif
186  /* Can't have an empty union */
187  int dummy;
188  } msg;
189 };
190 
191 /**
192  * The custom window manager information structure.
193  *
194  * When this structure is returned, it holds information about which
195  * low level system it is using, and will be one of SDL_SYSWM_TYPE.
196  */
198 {
201  union
202  {
203 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
204  struct
205  {
206  HWND window; /**< The window handle */
207  HDC hdc; /**< The window device context */
208  HINSTANCE hinstance; /**< The instance handle */
209  } win;
210 #endif
211 #if defined(SDL_VIDEO_DRIVER_WINRT)
212  struct
213  {
214  IInspectable * window; /**< The WinRT CoreWindow */
215  } winrt;
216 #endif
217 #if defined(SDL_VIDEO_DRIVER_X11)
218  struct
219  {
220  Display *display; /**< The X11 display */
221  Window window; /**< The X11 window */
222  } x11;
223 #endif
224 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
225  struct
226  {
227  IDirectFB *dfb; /**< The directfb main interface */
228  IDirectFBWindow *window; /**< The directfb window handle */
229  IDirectFBSurface *surface; /**< The directfb client surface */
230  } dfb;
231 #endif
232 #if defined(SDL_VIDEO_DRIVER_COCOA)
233  struct
234  {
235 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
236  NSWindow __unsafe_unretained *window; /**< The Cocoa window */
237 #else
238  NSWindow *window; /**< The Cocoa window */
239 #endif
240  } cocoa;
241 #endif
242 #if defined(SDL_VIDEO_DRIVER_UIKIT)
243  struct
244  {
245 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
246  UIWindow __unsafe_unretained *window; /**< The UIKit window */
247 #else
248  UIWindow *window; /**< The UIKit window */
249 #endif
250  GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
251  GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
252  GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
253  } uikit;
254 #endif
255 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
256  struct
257  {
258  struct wl_display *display; /**< Wayland display */
259  struct wl_surface *surface; /**< Wayland surface */
260  struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
261  } wl;
262 #endif
263 #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
264  struct
265  {
266  void *connection; /**< Mir display server connection */
267  void *surface; /**< Mir surface */
268  } mir;
269 #endif
270 
271 #if defined(SDL_VIDEO_DRIVER_ANDROID)
272  struct
273  {
274  ANativeWindow *window;
276  } android;
277 #endif
278 
279 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
280  struct
281  {
284  } vivante;
285 #endif
286 
287  /* Make sure this union is always 64 bytes (8 64-bit pointers). */
288  /* Be careful not to overflow this if you add a new target! */
290  } info;
291 };
292 
293 #endif /* SDL_PROTOTYPES_ONLY */
294 
295 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
296 
297 /* Function prototypes */
298 /**
299  * \brief This function allows access to driver-dependent window information.
300  *
301  * \param window The window about which information is being requested
302  * \param info This structure must be initialized with the SDL version, and is
303  * then filled in with information about the given window.
304  *
305  * \return SDL_TRUE if the function is implemented and the version member of
306  * the \c info struct is valid, SDL_FALSE otherwise.
307  *
308  * You typically use this function like this:
309  * \code
310  * SDL_SysWMinfo info;
311  * SDL_VERSION(&info.version);
312  * if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
313  * \endcode
314  */
316  SDL_SysWMinfo * info);
317 
318 
319 /* Ends C function definitions when using C++ */
320 #ifdef __cplusplus
321 }
322 #endif
323 #include "close_code.h"
324 
325 #endif /* SDL_syswm_h_ */
326 
327 /* vi: set ts=4 sw=4 expandtab: */
SDL_SYSWM_UNKNOWN
@ SDL_SYSWM_UNKNOWN
Definition: SDL_syswm.h:121
SDL_SysWMmsg
Definition: SDL_syswm.h:138
DECLSPEC
#define DECLSPEC
Definition: SDL_internal.h:48
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_SysWMmsg::subsystem
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:141
SDL_SysWMinfo::display
Display * display
Definition: SDL_syswm.h:220
SDL_SYSWM_WINRT
@ SDL_SYSWM_WINRT
Definition: SDL_syswm.h:129
surface
EGLSurface surface
Definition: eglext.h:248
SDL_version
Information the version of SDL in use.
Definition: SDL_version.h:51
SDL_SYSWM_DIRECTFB
@ SDL_SYSWM_DIRECTFB
Definition: SDL_syswm.h:124
SDL_error.h
SDL_SysWMinfo
Definition: SDL_syswm.h:197
SDL_SysWMmsg::version
SDL_version version
Definition: SDL_syswm.h:140
SDLCALL
#define SDLCALL
Definition: SDL_internal.h:49
SDL_SYSWM_TYPE
SDL_SYSWM_TYPE
Definition: SDL_syswm.h:119
SDL_SysWMinfo::window
Window window
Definition: SDL_syswm.h:221
SDL_SYSWM_ANDROID
@ SDL_SYSWM_ANDROID
Definition: SDL_syswm.h:130
SDL_SysWMmsg::msg
union SDL_SysWMmsg::@15 msg
SDL_SYSWM_WAYLAND
@ SDL_SYSWM_WAYLAND
Definition: SDL_syswm.h:127
close_code.h
SDL_SysWMinfo::info
union SDL_SysWMinfo::@17 info
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
begin_code.h
SDL_SYSWM_COCOA
@ SDL_SYSWM_COCOA
Definition: SDL_syswm.h:125
SDL_SysWMinfo::subsystem
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:200
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_SYSWM_X11
@ SDL_SYSWM_X11
Definition: SDL_syswm.h:123
SDL_SysWMinfo::x11
struct SDL_SysWMinfo::@17::@18 x11
SDL_SYSWM_UIKIT
@ SDL_SYSWM_UIKIT
Definition: SDL_syswm.h:126
SDL_SysWMmsg::event
XEvent event
Definition: SDL_syswm.h:154
EGLNativeWindowType
HWND EGLNativeWindowType
Definition: eglplatform.h:78
SDL_SysWMmsg::x11
struct SDL_SysWMmsg::@15::@16 x11
SDL_SysWMinfo::version
SDL_version version
Definition: SDL_syswm.h:199
framebuffer
GLuint framebuffer
Definition: SDL_opengl_glext.h:1174
SDL_stdinc.h
SDL_GetWindowWMInfo
SDL_bool SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *info)
This function allows access to driver-dependent window information.
Definition: SDL_video.c:3737
EGLNativeDisplayType
HDC EGLNativeDisplayType
Definition: eglplatform.h:76
SDL_video.h
EGLSurface
void * EGLSurface
Definition: egl.h:59
GLuint
unsigned int GLuint
Definition: SDL_opengl.h:185
SDL_version.h
SDL_SYSWM_MIR
@ SDL_SYSWM_MIR
Definition: SDL_syswm.h:128
SDL_SYSWM_VIVANTE
@ SDL_SYSWM_VIVANTE
Definition: SDL_syswm.h:131
SDL_SysWMmsg::dummy
int dummy
Definition: SDL_syswm.h:187
SDL_egl.h
SDL_SysWMinfo::dummy
Uint8 dummy[64]
Definition: SDL_syswm.h:289
SDL_SYSWM_OS2
@ SDL_SYSWM_OS2
Definition: SDL_syswm.h:132
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_SYSWM_WINDOWS
@ SDL_SYSWM_WINDOWS
Definition: SDL_syswm.h:122
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179