Change std:vector to eina_array
[platform/upstream/SDL.git] / include / SDL_syswm.h
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
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 #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)
124 /**
125  *  These are the various supported windowing subsystems
126  */
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_TIZEN,
141     SDL_SYSWM_OS2,
142     SDL_SYSWM_HAIKU
143 } SDL_SYSWM_TYPE;
144
145 /**
146  *  The custom event structure.
147  */
148 struct SDL_SysWMmsg
149 {
150     SDL_version version;
151     SDL_SYSWM_TYPE subsystem;
152     union
153     {
154 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
155         struct {
156             HWND hwnd;                  /**< The window for the message */
157             UINT msg;                   /**< The type of message */
158             WPARAM wParam;              /**< WORD message parameter */
159             LPARAM lParam;              /**< LONG message parameter */
160         } win;
161 #endif
162 #if defined(SDL_VIDEO_DRIVER_X11)
163         struct {
164             XEvent event;
165         } x11;
166 #endif
167 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
168         struct {
169             DFBEvent event;
170         } dfb;
171 #endif
172 #if defined(SDL_VIDEO_DRIVER_COCOA)
173         struct
174         {
175             /* Latest version of Xcode clang complains about empty structs in C v. C++:
176                  error: empty struct has size 0 in C, size 1 in C++
177              */
178             int dummy;
179             /* No Cocoa window events yet */
180         } cocoa;
181 #endif
182 #if defined(SDL_VIDEO_DRIVER_UIKIT)
183         struct
184         {
185             int dummy;
186             /* No UIKit window events yet */
187         } uikit;
188 #endif
189 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
190         struct
191         {
192             int dummy;
193             /* No Vivante window events yet */
194         } vivante;
195 #endif
196 #if defined(SDL_VIDEO_DRIVER_OS2)
197         struct
198         {
199             BOOL fFrame;                /**< TRUE if hwnd is a frame window */
200             HWND hwnd;                  /**< The window receiving the message */
201             ULONG msg;                  /**< The message identifier */
202             MPARAM mp1;                 /**< The first first message parameter */
203             MPARAM mp2;                 /**< The second first message parameter */
204         } os2;
205 #endif
206         /* Can't have an empty union */
207         int dummy;
208     } msg;
209 };
210
211 /**
212  *  The custom window manager information structure.
213  *
214  *  When this structure is returned, it holds information about which
215  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
216  */
217 struct SDL_SysWMinfo
218 {
219     SDL_version version;
220     SDL_SYSWM_TYPE subsystem;
221     union
222     {
223 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
224         struct
225         {
226             HWND window;                /**< The window handle */
227             HDC hdc;                    /**< The window device context */
228             HINSTANCE hinstance;        /**< The instance handle */
229         } win;
230 #endif
231 #if defined(SDL_VIDEO_DRIVER_WINRT)
232         struct
233         {
234             IInspectable * window;      /**< The WinRT CoreWindow */
235         } winrt;
236 #endif
237 #if defined(SDL_VIDEO_DRIVER_X11)
238         struct
239         {
240             Display *display;           /**< The X11 display */
241             Window window;              /**< The X11 window */
242         } x11;
243 #endif
244 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
245         struct
246         {
247             IDirectFB *dfb;             /**< The directfb main interface */
248             IDirectFBWindow *window;    /**< The directfb window handle */
249             IDirectFBSurface *surface;  /**< The directfb client surface */
250         } dfb;
251 #endif
252 #if defined(SDL_VIDEO_DRIVER_COCOA)
253         struct
254         {
255 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
256             NSWindow __unsafe_unretained *window; /**< The Cocoa window */
257 #else
258             NSWindow *window;                     /**< The Cocoa window */
259 #endif
260         } cocoa;
261 #endif
262 #if defined(SDL_VIDEO_DRIVER_UIKIT)
263         struct
264         {
265 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
266             UIWindow __unsafe_unretained *window; /**< The UIKit window */
267 #else
268             UIWindow *window;                     /**< The UIKit window */
269 #endif
270             GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
271             GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
272             GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
273         } uikit;
274 #endif
275 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
276         struct
277         {
278             struct wl_display *display;            /**< Wayland display */
279             struct wl_surface *surface;            /**< Wayland surface */
280             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
281         } wl;
282 #endif
283 #if defined(SDL_VIDEO_DRIVER_MIR)  /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
284         struct
285         {
286             void *connection;  /**< Mir display server connection */
287             void *surface;  /**< Mir surface */
288         } mir;
289 #endif
290
291 #if defined(SDL_VIDEO_DRIVER_ANDROID)
292         struct
293         {
294             ANativeWindow *window;
295             EGLSurface surface;
296         } android;
297 #endif
298 #if defined(SDL_VIDEO_DRIVER_TIZEN)
299         struct
300         {
301 //            struct wl_display *display;              /**< Wayland display */
302 //            struct wl_surface *surface;              /**< Wayland surface */
303 //            struct wl_shell_surface *shell_surface;  /**< Wayland shell_surface (window manager handle) */
304
305             /* For GLES */
306             void*  egl_display;                      /**< EGLDispaly when OPENGLES is enabled */
307             void*  egl_surface;                      /**< EGLSurface when OPENGLES is enabled for this wl_surface */
308         } tizen;
309 #endif
310
311 #if defined(SDL_VIDEO_DRIVER_OS2)
312         struct
313         {
314             HWND hwnd;                  /**< The window handle */
315             HWND hwndFrame;             /**< The frame window handle */
316         } os2;
317 #endif
318
319 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
320         struct
321         {
322             EGLNativeDisplayType display;
323             EGLNativeWindowType window;
324         } vivante;
325 #endif
326
327         /* Make sure this union is always 64 bytes (8 64-bit pointers). */
328         /* Be careful not to overflow this if you add a new target! */
329         Uint8 dummy[64];
330     } info;
331 };
332
333 #endif /* SDL_PROTOTYPES_ONLY */
334
335 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
336
337 /* Function prototypes */
338 /**
339  *  \brief This function allows access to driver-dependent window information.
340  *
341  *  \param window The window about which information is being requested
342  *  \param info This structure must be initialized with the SDL version, and is
343  *              then filled in with information about the given window.
344  *
345  *  \return SDL_TRUE if the function is implemented and the version member of
346  *          the \c info struct is valid, SDL_FALSE otherwise.
347  *
348  *  You typically use this function like this:
349  *  \code
350  *  SDL_SysWMinfo info;
351  *  SDL_VERSION(&info.version);
352  *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
353  *  \endcode
354  */
355 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
356                                                      SDL_SysWMinfo * info);
357
358
359 /* Ends C function definitions when using C++ */
360 #ifdef __cplusplus
361 }
362 #endif
363 #include "close_code.h"
364
365 #endif /* SDL_syswm_h_ */
366
367 /* vi: set ts=4 sw=4 expandtab: */