SDL standard library
SDL_syswm.h@0:dda4f4550403, 2016-09-07 (annotated)
- Committer:
- miruga27
- Date:
- Wed Sep 07 18:46:53 2016 +0000
- Revision:
- 0:dda4f4550403
7/09/2016;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:dda4f4550403 | 1 | /* |
miruga27 | 0:dda4f4550403 | 2 | Simple DirectMedia Layer |
miruga27 | 0:dda4f4550403 | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:dda4f4550403 | 4 | |
miruga27 | 0:dda4f4550403 | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:dda4f4550403 | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:dda4f4550403 | 7 | arising from the use of this software. |
miruga27 | 0:dda4f4550403 | 8 | |
miruga27 | 0:dda4f4550403 | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:dda4f4550403 | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:dda4f4550403 | 11 | freely, subject to the following restrictions: |
miruga27 | 0:dda4f4550403 | 12 | |
miruga27 | 0:dda4f4550403 | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:dda4f4550403 | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:dda4f4550403 | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:dda4f4550403 | 16 | appreciated but is not required. |
miruga27 | 0:dda4f4550403 | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:dda4f4550403 | 18 | misrepresented as being the original software. |
miruga27 | 0:dda4f4550403 | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:dda4f4550403 | 20 | */ |
miruga27 | 0:dda4f4550403 | 21 | |
miruga27 | 0:dda4f4550403 | 22 | /** |
miruga27 | 0:dda4f4550403 | 23 | * \file SDL_syswm.h |
miruga27 | 0:dda4f4550403 | 24 | * |
miruga27 | 0:dda4f4550403 | 25 | * Include file for SDL custom system window manager hooks. |
miruga27 | 0:dda4f4550403 | 26 | */ |
miruga27 | 0:dda4f4550403 | 27 | |
miruga27 | 0:dda4f4550403 | 28 | #ifndef _SDL_syswm_h |
miruga27 | 0:dda4f4550403 | 29 | #define _SDL_syswm_h |
miruga27 | 0:dda4f4550403 | 30 | |
miruga27 | 0:dda4f4550403 | 31 | #include "SDL_stdinc.h" |
miruga27 | 0:dda4f4550403 | 32 | #include "SDL_error.h" |
miruga27 | 0:dda4f4550403 | 33 | #include "SDL_video.h" |
miruga27 | 0:dda4f4550403 | 34 | #include "SDL_version.h" |
miruga27 | 0:dda4f4550403 | 35 | |
miruga27 | 0:dda4f4550403 | 36 | #include "begin_code.h" |
miruga27 | 0:dda4f4550403 | 37 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:dda4f4550403 | 38 | #ifdef __cplusplus |
miruga27 | 0:dda4f4550403 | 39 | extern "C" { |
miruga27 | 0:dda4f4550403 | 40 | #endif |
miruga27 | 0:dda4f4550403 | 41 | |
miruga27 | 0:dda4f4550403 | 42 | /** |
miruga27 | 0:dda4f4550403 | 43 | * \file SDL_syswm.h |
miruga27 | 0:dda4f4550403 | 44 | * |
miruga27 | 0:dda4f4550403 | 45 | * Your application has access to a special type of event ::SDL_SYSWMEVENT, |
miruga27 | 0:dda4f4550403 | 46 | * which contains window-manager specific information and arrives whenever |
miruga27 | 0:dda4f4550403 | 47 | * an unhandled window event occurs. This event is ignored by default, but |
miruga27 | 0:dda4f4550403 | 48 | * you can enable it with SDL_EventState(). |
miruga27 | 0:dda4f4550403 | 49 | */ |
miruga27 | 0:dda4f4550403 | 50 | #ifdef SDL_PROTOTYPES_ONLY |
miruga27 | 0:dda4f4550403 | 51 | struct SDL_SysWMinfo; |
miruga27 | 0:dda4f4550403 | 52 | #else |
miruga27 | 0:dda4f4550403 | 53 | |
miruga27 | 0:dda4f4550403 | 54 | #if defined(SDL_VIDEO_DRIVER_WINDOWS) |
miruga27 | 0:dda4f4550403 | 55 | #define WIN32_LEAN_AND_MEAN |
miruga27 | 0:dda4f4550403 | 56 | #include <windows.h> |
miruga27 | 0:dda4f4550403 | 57 | #endif |
miruga27 | 0:dda4f4550403 | 58 | |
miruga27 | 0:dda4f4550403 | 59 | /* This is the structure for custom window manager events */ |
miruga27 | 0:dda4f4550403 | 60 | #if defined(SDL_VIDEO_DRIVER_X11) |
miruga27 | 0:dda4f4550403 | 61 | #if defined(__APPLE__) && defined(__MACH__) |
miruga27 | 0:dda4f4550403 | 62 | /* conflicts with Quickdraw.h */ |
miruga27 | 0:dda4f4550403 | 63 | #define Cursor X11Cursor |
miruga27 | 0:dda4f4550403 | 64 | #endif |
miruga27 | 0:dda4f4550403 | 65 | |
miruga27 | 0:dda4f4550403 | 66 | #include <X11/Xlib.h> |
miruga27 | 0:dda4f4550403 | 67 | #include <X11/Xatom.h> |
miruga27 | 0:dda4f4550403 | 68 | |
miruga27 | 0:dda4f4550403 | 69 | #if defined(__APPLE__) && defined(__MACH__) |
miruga27 | 0:dda4f4550403 | 70 | /* matches the re-define above */ |
miruga27 | 0:dda4f4550403 | 71 | #undef Cursor |
miruga27 | 0:dda4f4550403 | 72 | #endif |
miruga27 | 0:dda4f4550403 | 73 | |
miruga27 | 0:dda4f4550403 | 74 | #endif /* defined(SDL_VIDEO_DRIVER_X11) */ |
miruga27 | 0:dda4f4550403 | 75 | |
miruga27 | 0:dda4f4550403 | 76 | #if defined(SDL_VIDEO_DRIVER_DIRECTFB) |
miruga27 | 0:dda4f4550403 | 77 | #include <directfb.h> |
miruga27 | 0:dda4f4550403 | 78 | #endif |
miruga27 | 0:dda4f4550403 | 79 | |
miruga27 | 0:dda4f4550403 | 80 | #if defined(SDL_VIDEO_DRIVER_COCOA) |
miruga27 | 0:dda4f4550403 | 81 | #ifdef __OBJC__ |
miruga27 | 0:dda4f4550403 | 82 | #include <Cocoa/Cocoa.h> |
miruga27 | 0:dda4f4550403 | 83 | #else |
miruga27 | 0:dda4f4550403 | 84 | typedef struct _NSWindow NSWindow; |
miruga27 | 0:dda4f4550403 | 85 | #endif |
miruga27 | 0:dda4f4550403 | 86 | #endif |
miruga27 | 0:dda4f4550403 | 87 | |
miruga27 | 0:dda4f4550403 | 88 | #if defined(SDL_VIDEO_DRIVER_UIKIT) |
miruga27 | 0:dda4f4550403 | 89 | #ifdef __OBJC__ |
miruga27 | 0:dda4f4550403 | 90 | #include <UIKit/UIKit.h> |
miruga27 | 0:dda4f4550403 | 91 | #else |
miruga27 | 0:dda4f4550403 | 92 | typedef struct _UIWindow UIWindow; |
miruga27 | 0:dda4f4550403 | 93 | #endif |
miruga27 | 0:dda4f4550403 | 94 | #endif |
miruga27 | 0:dda4f4550403 | 95 | |
miruga27 | 0:dda4f4550403 | 96 | #if defined(SDL_VIDEO_DRIVER_MIR) |
miruga27 | 0:dda4f4550403 | 97 | #include <mir_toolkit/mir_client_library.h> |
miruga27 | 0:dda4f4550403 | 98 | #endif |
miruga27 | 0:dda4f4550403 | 99 | |
miruga27 | 0:dda4f4550403 | 100 | |
miruga27 | 0:dda4f4550403 | 101 | /** |
miruga27 | 0:dda4f4550403 | 102 | * These are the various supported windowing subsystems |
miruga27 | 0:dda4f4550403 | 103 | */ |
miruga27 | 0:dda4f4550403 | 104 | typedef enum |
miruga27 | 0:dda4f4550403 | 105 | { |
miruga27 | 0:dda4f4550403 | 106 | SDL_SYSWM_UNKNOWN, |
miruga27 | 0:dda4f4550403 | 107 | SDL_SYSWM_WINDOWS, |
miruga27 | 0:dda4f4550403 | 108 | SDL_SYSWM_X11, |
miruga27 | 0:dda4f4550403 | 109 | SDL_SYSWM_DIRECTFB, |
miruga27 | 0:dda4f4550403 | 110 | SDL_SYSWM_COCOA, |
miruga27 | 0:dda4f4550403 | 111 | SDL_SYSWM_UIKIT, |
miruga27 | 0:dda4f4550403 | 112 | SDL_SYSWM_WAYLAND, |
miruga27 | 0:dda4f4550403 | 113 | SDL_SYSWM_MIR, |
miruga27 | 0:dda4f4550403 | 114 | } SDL_SYSWM_TYPE; |
miruga27 | 0:dda4f4550403 | 115 | |
miruga27 | 0:dda4f4550403 | 116 | /** |
miruga27 | 0:dda4f4550403 | 117 | * The custom event structure. |
miruga27 | 0:dda4f4550403 | 118 | */ |
miruga27 | 0:dda4f4550403 | 119 | struct SDL_SysWMmsg |
miruga27 | 0:dda4f4550403 | 120 | { |
miruga27 | 0:dda4f4550403 | 121 | SDL_version version; |
miruga27 | 0:dda4f4550403 | 122 | SDL_SYSWM_TYPE subsystem; |
miruga27 | 0:dda4f4550403 | 123 | union |
miruga27 | 0:dda4f4550403 | 124 | { |
miruga27 | 0:dda4f4550403 | 125 | #if defined(SDL_VIDEO_DRIVER_WINDOWS) |
miruga27 | 0:dda4f4550403 | 126 | struct { |
miruga27 | 0:dda4f4550403 | 127 | HWND hwnd; /**< The window for the message */ |
miruga27 | 0:dda4f4550403 | 128 | UINT msg; /**< The type of message */ |
miruga27 | 0:dda4f4550403 | 129 | WPARAM wParam; /**< WORD message parameter */ |
miruga27 | 0:dda4f4550403 | 130 | LPARAM lParam; /**< LONG message parameter */ |
miruga27 | 0:dda4f4550403 | 131 | } win; |
miruga27 | 0:dda4f4550403 | 132 | #endif |
miruga27 | 0:dda4f4550403 | 133 | #if defined(SDL_VIDEO_DRIVER_X11) |
miruga27 | 0:dda4f4550403 | 134 | struct { |
miruga27 | 0:dda4f4550403 | 135 | XEvent event; |
miruga27 | 0:dda4f4550403 | 136 | } x11; |
miruga27 | 0:dda4f4550403 | 137 | #endif |
miruga27 | 0:dda4f4550403 | 138 | #if defined(SDL_VIDEO_DRIVER_DIRECTFB) |
miruga27 | 0:dda4f4550403 | 139 | struct { |
miruga27 | 0:dda4f4550403 | 140 | DFBEvent event; |
miruga27 | 0:dda4f4550403 | 141 | } dfb; |
miruga27 | 0:dda4f4550403 | 142 | #endif |
miruga27 | 0:dda4f4550403 | 143 | #if defined(SDL_VIDEO_DRIVER_COCOA) |
miruga27 | 0:dda4f4550403 | 144 | struct |
miruga27 | 0:dda4f4550403 | 145 | { |
miruga27 | 0:dda4f4550403 | 146 | /* No Cocoa window events yet */ |
miruga27 | 0:dda4f4550403 | 147 | } cocoa; |
miruga27 | 0:dda4f4550403 | 148 | #endif |
miruga27 | 0:dda4f4550403 | 149 | #if defined(SDL_VIDEO_DRIVER_UIKIT) |
miruga27 | 0:dda4f4550403 | 150 | struct |
miruga27 | 0:dda4f4550403 | 151 | { |
miruga27 | 0:dda4f4550403 | 152 | /* No UIKit window events yet */ |
miruga27 | 0:dda4f4550403 | 153 | } uikit; |
miruga27 | 0:dda4f4550403 | 154 | #endif |
miruga27 | 0:dda4f4550403 | 155 | /* Can't have an empty union */ |
miruga27 | 0:dda4f4550403 | 156 | int dummy; |
miruga27 | 0:dda4f4550403 | 157 | } msg; |
miruga27 | 0:dda4f4550403 | 158 | }; |
miruga27 | 0:dda4f4550403 | 159 | |
miruga27 | 0:dda4f4550403 | 160 | /** |
miruga27 | 0:dda4f4550403 | 161 | * The custom window manager information structure. |
miruga27 | 0:dda4f4550403 | 162 | * |
miruga27 | 0:dda4f4550403 | 163 | * When this structure is returned, it holds information about which |
miruga27 | 0:dda4f4550403 | 164 | * low level system it is using, and will be one of SDL_SYSWM_TYPE. |
miruga27 | 0:dda4f4550403 | 165 | */ |
miruga27 | 0:dda4f4550403 | 166 | struct SDL_SysWMinfo |
miruga27 | 0:dda4f4550403 | 167 | { |
miruga27 | 0:dda4f4550403 | 168 | SDL_version version; |
miruga27 | 0:dda4f4550403 | 169 | SDL_SYSWM_TYPE subsystem; |
miruga27 | 0:dda4f4550403 | 170 | union |
miruga27 | 0:dda4f4550403 | 171 | { |
miruga27 | 0:dda4f4550403 | 172 | #if defined(SDL_VIDEO_DRIVER_WINDOWS) |
miruga27 | 0:dda4f4550403 | 173 | struct |
miruga27 | 0:dda4f4550403 | 174 | { |
miruga27 | 0:dda4f4550403 | 175 | HWND window; /**< The window handle */ |
miruga27 | 0:dda4f4550403 | 176 | } win; |
miruga27 | 0:dda4f4550403 | 177 | #endif |
miruga27 | 0:dda4f4550403 | 178 | #if defined(SDL_VIDEO_DRIVER_X11) |
miruga27 | 0:dda4f4550403 | 179 | struct |
miruga27 | 0:dda4f4550403 | 180 | { |
miruga27 | 0:dda4f4550403 | 181 | Display *display; /**< The X11 display */ |
miruga27 | 0:dda4f4550403 | 182 | Window window; /**< The X11 window */ |
miruga27 | 0:dda4f4550403 | 183 | } x11; |
miruga27 | 0:dda4f4550403 | 184 | #endif |
miruga27 | 0:dda4f4550403 | 185 | #if defined(SDL_VIDEO_DRIVER_DIRECTFB) |
miruga27 | 0:dda4f4550403 | 186 | struct |
miruga27 | 0:dda4f4550403 | 187 | { |
miruga27 | 0:dda4f4550403 | 188 | IDirectFB *dfb; /**< The directfb main interface */ |
miruga27 | 0:dda4f4550403 | 189 | IDirectFBWindow *window; /**< The directfb window handle */ |
miruga27 | 0:dda4f4550403 | 190 | IDirectFBSurface *surface; /**< The directfb client surface */ |
miruga27 | 0:dda4f4550403 | 191 | } dfb; |
miruga27 | 0:dda4f4550403 | 192 | #endif |
miruga27 | 0:dda4f4550403 | 193 | #if defined(SDL_VIDEO_DRIVER_COCOA) |
miruga27 | 0:dda4f4550403 | 194 | struct |
miruga27 | 0:dda4f4550403 | 195 | { |
miruga27 | 0:dda4f4550403 | 196 | NSWindow *window; /* The Cocoa window */ |
miruga27 | 0:dda4f4550403 | 197 | } cocoa; |
miruga27 | 0:dda4f4550403 | 198 | #endif |
miruga27 | 0:dda4f4550403 | 199 | #if defined(SDL_VIDEO_DRIVER_UIKIT) |
miruga27 | 0:dda4f4550403 | 200 | struct |
miruga27 | 0:dda4f4550403 | 201 | { |
miruga27 | 0:dda4f4550403 | 202 | UIWindow *window; /* The UIKit window */ |
miruga27 | 0:dda4f4550403 | 203 | } uikit; |
miruga27 | 0:dda4f4550403 | 204 | #endif |
miruga27 | 0:dda4f4550403 | 205 | #if defined(SDL_VIDEO_DRIVER_WAYLAND) |
miruga27 | 0:dda4f4550403 | 206 | struct |
miruga27 | 0:dda4f4550403 | 207 | { |
miruga27 | 0:dda4f4550403 | 208 | struct wl_display *display; /**< Wayland display */ |
miruga27 | 0:dda4f4550403 | 209 | struct wl_surface *surface; /**< Wayland surface */ |
miruga27 | 0:dda4f4550403 | 210 | struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ |
miruga27 | 0:dda4f4550403 | 211 | } wl; |
miruga27 | 0:dda4f4550403 | 212 | #endif |
miruga27 | 0:dda4f4550403 | 213 | #if defined(SDL_VIDEO_DRIVER_MIR) |
miruga27 | 0:dda4f4550403 | 214 | struct |
miruga27 | 0:dda4f4550403 | 215 | { |
miruga27 | 0:dda4f4550403 | 216 | MirConnection *connection; /**< Mir display server connection */ |
miruga27 | 0:dda4f4550403 | 217 | MirSurface *surface; /**< Mir surface */ |
miruga27 | 0:dda4f4550403 | 218 | } mir; |
miruga27 | 0:dda4f4550403 | 219 | #endif |
miruga27 | 0:dda4f4550403 | 220 | |
miruga27 | 0:dda4f4550403 | 221 | /* Can't have an empty union */ |
miruga27 | 0:dda4f4550403 | 222 | int dummy; |
miruga27 | 0:dda4f4550403 | 223 | } info; |
miruga27 | 0:dda4f4550403 | 224 | }; |
miruga27 | 0:dda4f4550403 | 225 | |
miruga27 | 0:dda4f4550403 | 226 | #endif /* SDL_PROTOTYPES_ONLY */ |
miruga27 | 0:dda4f4550403 | 227 | |
miruga27 | 0:dda4f4550403 | 228 | typedef struct SDL_SysWMinfo SDL_SysWMinfo; |
miruga27 | 0:dda4f4550403 | 229 | |
miruga27 | 0:dda4f4550403 | 230 | /* Function prototypes */ |
miruga27 | 0:dda4f4550403 | 231 | /** |
miruga27 | 0:dda4f4550403 | 232 | * \brief This function allows access to driver-dependent window information. |
miruga27 | 0:dda4f4550403 | 233 | * |
miruga27 | 0:dda4f4550403 | 234 | * \param window The window about which information is being requested |
miruga27 | 0:dda4f4550403 | 235 | * \param info This structure must be initialized with the SDL version, and is |
miruga27 | 0:dda4f4550403 | 236 | * then filled in with information about the given window. |
miruga27 | 0:dda4f4550403 | 237 | * |
miruga27 | 0:dda4f4550403 | 238 | * \return SDL_TRUE if the function is implemented and the version member of |
miruga27 | 0:dda4f4550403 | 239 | * the \c info struct is valid, SDL_FALSE otherwise. |
miruga27 | 0:dda4f4550403 | 240 | * |
miruga27 | 0:dda4f4550403 | 241 | * You typically use this function like this: |
miruga27 | 0:dda4f4550403 | 242 | * \code |
miruga27 | 0:dda4f4550403 | 243 | * SDL_SysWMinfo info; |
miruga27 | 0:dda4f4550403 | 244 | * SDL_VERSION(&info.version); |
miruga27 | 0:dda4f4550403 | 245 | * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } |
miruga27 | 0:dda4f4550403 | 246 | * \endcode |
miruga27 | 0:dda4f4550403 | 247 | */ |
miruga27 | 0:dda4f4550403 | 248 | extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, |
miruga27 | 0:dda4f4550403 | 249 | SDL_SysWMinfo * info); |
miruga27 | 0:dda4f4550403 | 250 | |
miruga27 | 0:dda4f4550403 | 251 | |
miruga27 | 0:dda4f4550403 | 252 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:dda4f4550403 | 253 | #ifdef __cplusplus |
miruga27 | 0:dda4f4550403 | 254 | } |
miruga27 | 0:dda4f4550403 | 255 | #endif |
miruga27 | 0:dda4f4550403 | 256 | #include "close_code.h" |
miruga27 | 0:dda4f4550403 | 257 | |
miruga27 | 0:dda4f4550403 | 258 | #endif /* _SDL_syswm_h */ |
miruga27 | 0:dda4f4550403 | 259 | |
miruga27 | 0:dda4f4550403 | 260 | /* vi: set ts=4 sw=4 expandtab: */ |