My Project
SDL_syswm.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 
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 
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 #ifndef NOMINMAX /* don't define min() and max(). */
53 #define NOMINMAX
54 #endif
55 #include <windows.h>
56 #endif
57 
58 #if defined(SDL_VIDEO_DRIVER_WINRT)
59 #include <Inspectable.h>
60 #endif
61 
62 /* This is the structure for custom window manager events */
63 #if defined(SDL_VIDEO_DRIVER_X11)
64 #if defined(__APPLE__) && defined(__MACH__)
65 /* conflicts with Quickdraw.h */
66 #define Cursor X11Cursor
67 #endif
68 
69 #include <X11/Xlib.h>
70 #include <X11/Xatom.h>
71 
72 #if defined(__APPLE__) && defined(__MACH__)
73 /* matches the re-define above */
74 #undef Cursor
75 #endif
76 
77 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
78 
79 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
80 #include <directfb.h>
81 #endif
82 
83 #if defined(SDL_VIDEO_DRIVER_COCOA)
84 #ifdef __OBJC__
85 @class NSWindow;
86 #else
87 typedef struct _NSWindow NSWindow;
88 #endif
89 #endif
90 
91 #if defined(SDL_VIDEO_DRIVER_UIKIT)
92 #ifdef __OBJC__
93 #include <UIKit/UIKit.h>
94 #else
95 typedef struct _UIWindow UIWindow;
96 typedef struct _UIViewController UIViewController;
97 #endif
98 typedef Uint32 GLuint;
99 #endif
100 
101 #if defined(SDL_VIDEO_DRIVER_ANDROID)
102 typedef struct ANativeWindow ANativeWindow;
103 typedef void *EGLSurface;
104 #endif
105 
106 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
107 #include "SDL_egl.h"
108 #endif
109 
110 #if defined(SDL_VIDEO_DRIVER_OS2)
111 #define INCL_WIN
112 #include <os2.h>
113 #endif
114 #endif /* SDL_PROTOTYPES_ONLY */
115 
116 
117 #include "begin_code.h"
118 /* Set up for C function definitions, even when using C++ */
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
123 #if !defined(SDL_PROTOTYPES_ONLY)
127 typedef enum
128 {
129  SDL_SYSWM_UNKNOWN,
130  SDL_SYSWM_WINDOWS,
131  SDL_SYSWM_X11,
132  SDL_SYSWM_DIRECTFB,
133  SDL_SYSWM_COCOA,
134  SDL_SYSWM_UIKIT,
135  SDL_SYSWM_WAYLAND,
136  SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
137  SDL_SYSWM_WINRT,
138  SDL_SYSWM_ANDROID,
139  SDL_SYSWM_VIVANTE,
140  SDL_SYSWM_OS2,
141  SDL_SYSWM_HAIKU
143 
148 {
149  SDL_version version;
150  SDL_SYSWM_TYPE subsystem;
151  union
152  {
153 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
154  struct {
155  HWND hwnd;
156  UINT msg;
157  WPARAM wParam;
158  LPARAM lParam;
159  } win;
160 #endif
161 #if defined(SDL_VIDEO_DRIVER_X11)
162  struct {
163  XEvent event;
164  } x11;
165 #endif
166 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
167  struct {
168  DFBEvent event;
169  } dfb;
170 #endif
171 #if defined(SDL_VIDEO_DRIVER_COCOA)
172  struct
173  {
174  /* Latest version of Xcode clang complains about empty structs in C v. C++:
175  error: empty struct has size 0 in C, size 1 in C++
176  */
177  int dummy;
178  /* No Cocoa window events yet */
179  } cocoa;
180 #endif
181 #if defined(SDL_VIDEO_DRIVER_UIKIT)
182  struct
183  {
184  int dummy;
185  /* No UIKit window events yet */
186  } uikit;
187 #endif
188 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
189  struct
190  {
191  int dummy;
192  /* No Vivante window events yet */
193  } vivante;
194 #endif
195 #if defined(SDL_VIDEO_DRIVER_OS2)
196  struct
197  {
198  BOOL fFrame;
199  HWND hwnd;
200  ULONG msg;
201  MPARAM mp1;
202  MPARAM mp2;
203  } os2;
204 #endif
205  /* Can't have an empty union */
206  int dummy;
207  } msg;
208 };
209 
217 {
218  SDL_version version;
219  SDL_SYSWM_TYPE subsystem;
220  union
221  {
222 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
223  struct
224  {
225  HWND window;
226  HDC hdc;
227  HINSTANCE hinstance;
228  } win;
229 #endif
230 #if defined(SDL_VIDEO_DRIVER_WINRT)
231  struct
232  {
233  IInspectable * window;
234  } winrt;
235 #endif
236 #if defined(SDL_VIDEO_DRIVER_X11)
237  struct
238  {
239  Display *display;
240  Window window;
241  } x11;
242 #endif
243 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
244  struct
245  {
246  IDirectFB *dfb;
247  IDirectFBWindow *window;
248  IDirectFBSurface *surface;
249  } dfb;
250 #endif
251 #if defined(SDL_VIDEO_DRIVER_COCOA)
252  struct
253  {
254 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
255  NSWindow __unsafe_unretained *window;
256 #else
257  NSWindow *window;
258 #endif
259  } cocoa;
260 #endif
261 #if defined(SDL_VIDEO_DRIVER_UIKIT)
262  struct
263  {
264 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
265  UIWindow __unsafe_unretained *window;
266 #else
267  UIWindow *window;
268 #endif
269  GLuint framebuffer;
270  GLuint colorbuffer;
271  GLuint resolveFramebuffer;
272  } uikit;
273 #endif
274 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
275  struct
276  {
277  struct wl_display *display;
278  struct wl_surface *surface;
279  struct wl_shell_surface *shell_surface;
280  } wl;
281 #endif
282 #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
283  struct
284  {
285  void *connection;
286  void *surface;
287  } mir;
288 #endif
289 
290 #if defined(SDL_VIDEO_DRIVER_ANDROID)
291  struct
292  {
293  ANativeWindow *window;
294  EGLSurface surface;
295  } android;
296 #endif
297 
298 #if defined(SDL_VIDEO_DRIVER_OS2)
299  struct
300  {
301  HWND hwnd;
302  HWND hwndFrame;
303  } os2;
304 #endif
305 
306 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
307  struct
308  {
309  EGLNativeDisplayType display;
310  EGLNativeWindowType window;
311  } vivante;
312 #endif
313 
314  /* Make sure this union is always 64 bytes (8 64-bit pointers). */
315  /* Be careful not to overflow this if you add a new target! */
316  Uint8 dummy[64];
317  } info;
318 };
319 
320 #endif /* SDL_PROTOTYPES_ONLY */
321 
322 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
323 
324 /* Function prototypes */
342 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
343  SDL_SysWMinfo * info);
344 
345 
346 /* Ends C function definitions when using C++ */
347 #ifdef __cplusplus
348 }
349 #endif
350 #include "close_code.h"
351 
352 #endif /* SDL_syswm_h_ */
353 
354 /* vi: set ts=4 sw=4 expandtab: */
SDL_SYSWM_TYPE
Definition: SDL_syswm.h:128
DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *info)
This function allows access to driver-dependent window information.
struct SDL_Window SDL_Window
The type used to identify a window.
Definition: SDL_video.h:90
Definition: SDL_syswm.h:217
struct wl_display * display
Definition: SDL_syswm.h:277
struct wl_surface * surface
Definition: SDL_syswm.h:278
Display * display
Definition: SDL_syswm.h:239
struct wl_shell_surface * shell_surface
Definition: SDL_syswm.h:279
Window window
Definition: SDL_syswm.h:240
Definition: SDL_syswm.h:148
Information the version of SDL in use.
Definition: SDL_version.h:52