2 Simple DirectMedia Layer
3 Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
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.
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:
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.
25 * Include file for SDL custom system window manager hooks.
31 #include "SDL_stdinc.h"
32 #include "SDL_error.h"
33 #include "SDL_video.h"
34 #include "SDL_version.h"
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().
46 #if !defined(SDL_PROTOTYPES_ONLY)
48 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
49 #ifndef WIN32_LEAN_AND_MEAN
50 #define WIN32_LEAN_AND_MEAN
52 #ifndef NOMINMAX /* don't define min() and max(). */
58 #if defined(SDL_VIDEO_DRIVER_WINRT)
59 #include <Inspectable.h>
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
70 #include <X11/Xatom.h>
72 #if defined(__APPLE__) && defined(__MACH__)
73 /* matches the re-define above */
77 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
79 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
83 #if defined(SDL_VIDEO_DRIVER_COCOA)
87 typedef struct _NSWindow NSWindow;
91 #if defined(SDL_VIDEO_DRIVER_UIKIT)
93 #include <UIKit/UIKit.h>
95 typedef struct _UIWindow UIWindow;
96 typedef struct _UIViewController UIViewController;
98 typedef Uint32 GLuint;
101 #if defined(SDL_VIDEO_DRIVER_ANDROID)
102 typedef struct ANativeWindow ANativeWindow;
103 typedef void *EGLSurface;
106 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
110 #if defined(SDL_VIDEO_DRIVER_OS2)
114 #endif /* SDL_PROTOTYPES_ONLY */
117 #include "begin_code.h"
118 /* Set up for C function definitions, even when using C++ */
123 #if !defined(SDL_PROTOTYPES_ONLY)
125 * These are the various supported windowing subsystems
136 SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
145 * The custom event structure.
150 SDL_SYSWM_TYPE subsystem;
153 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
155 HWND hwnd; /**< The window for the message */
156 UINT msg; /**< The type of message */
157 WPARAM wParam; /**< WORD message parameter */
158 LPARAM lParam; /**< LONG message parameter */
161 #if defined(SDL_VIDEO_DRIVER_X11)
166 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
171 #if defined(SDL_VIDEO_DRIVER_COCOA)
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++
178 /* No Cocoa window events yet */
181 #if defined(SDL_VIDEO_DRIVER_UIKIT)
185 /* No UIKit window events yet */
188 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
192 /* No Vivante window events yet */
195 #if defined(SDL_VIDEO_DRIVER_OS2)
198 BOOL fFrame; /**< TRUE if hwnd is a frame window */
199 HWND hwnd; /**< The window receiving the message */
200 ULONG msg; /**< The message identifier */
201 MPARAM mp1; /**< The first first message parameter */
202 MPARAM mp2; /**< The second first message parameter */
205 /* Can't have an empty union */
211 * The custom window manager information structure.
213 * When this structure is returned, it holds information about which
214 * low level system it is using, and will be one of SDL_SYSWM_TYPE.
219 SDL_SYSWM_TYPE subsystem;
222 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
225 HWND window; /**< The window handle */
226 HDC hdc; /**< The window device context */
227 HINSTANCE hinstance; /**< The instance handle */
230 #if defined(SDL_VIDEO_DRIVER_WINRT)
233 IInspectable * window; /**< The WinRT CoreWindow */
236 #if defined(SDL_VIDEO_DRIVER_X11)
239 Display *display; /**< The X11 display */
240 Window window; /**< The X11 window */
243 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
246 IDirectFB *dfb; /**< The directfb main interface */
247 IDirectFBWindow *window; /**< The directfb window handle */
248 IDirectFBSurface *surface; /**< The directfb client surface */
251 #if defined(SDL_VIDEO_DRIVER_COCOA)
254 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
255 NSWindow __unsafe_unretained *window; /**< The Cocoa window */
257 NSWindow *window; /**< The Cocoa window */
261 #if defined(SDL_VIDEO_DRIVER_UIKIT)
264 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
265 UIWindow __unsafe_unretained *window; /**< The UIKit window */
267 UIWindow *window; /**< The UIKit window */
269 GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
270 GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
271 GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
274 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
277 struct wl_display *display; /**< Wayland display */
278 struct wl_surface *surface; /**< Wayland surface */
279 struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
282 #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
285 void *connection; /**< Mir display server connection */
286 void *surface; /**< Mir surface */
290 #if defined(SDL_VIDEO_DRIVER_ANDROID)
293 ANativeWindow *window;
298 #if defined(SDL_VIDEO_DRIVER_OS2)
301 HWND hwnd; /**< The window handle */
302 HWND hwndFrame; /**< The frame window handle */
306 #if defined(SDL_VIDEO_DRIVER_VIVANTE)
309 EGLNativeDisplayType display;
310 EGLNativeWindowType window;
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! */
320 #endif /* SDL_PROTOTYPES_ONLY */
322 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
324 /* Function prototypes */
326 * \brief This function allows access to driver-dependent window information.
328 * \param window The window about which information is being requested
329 * \param info This structure must be initialized with the SDL version, and is
330 * then filled in with information about the given window.
332 * \return SDL_TRUE if the function is implemented and the version member of
333 * the \c info struct is valid, SDL_FALSE otherwise.
335 * You typically use this function like this:
337 * SDL_SysWMinfo info;
338 * SDL_VERSION(&info.version);
339 * if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
342 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
343 SDL_SysWMinfo * info);
346 /* Ends C function definitions when using C++ */
350 #include "close_code.h"
352 #endif /* SDL_syswm_h_ */
354 /* vi: set ts=4 sw=4 expandtab: */