1/* 2 SDL - Simple DirectMedia Layer 3 Copyright (C) 1997-2012 Sam Lantinga 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 19 Sam Lantinga 20 slouken@libsdl.org 21*/ 22 23/** @file SDL_syswm.h 24 * Include file for SDL custom system window manager hooks 25 */ 26 27#ifndef _SDL_syswm_h 28#define _SDL_syswm_h 29 30#include "SDL_stdinc.h" 31#include "SDL_error.h" 32#include "SDL_version.h" 33 34#include "begin_code.h" 35/* Set up for C function definitions, even when using C++ */ 36#ifdef __cplusplus 37extern "C" { 38#endif 39 40/** @file SDL_syswm.h 41 * Your application has access to a special type of event 'SDL_SYSWMEVENT', 42 * which contains window-manager specific information and arrives whenever 43 * an unhandled window event occurs. This event is ignored by default, but 44 * you can enable it with SDL_EventState() 45 */ 46#ifdef SDL_PROTOTYPES_ONLY 47struct SDL_SysWMinfo; 48typedef struct SDL_SysWMinfo SDL_SysWMinfo; 49#else 50 51/* This is the structure for custom window manager events */ 52#if defined(SDL_VIDEO_DRIVER_X11) 53#if defined(__APPLE__) && defined(__MACH__) 54/* conflicts with Quickdraw.h */ 55#define Cursor X11Cursor 56#endif 57 58#include <X11/Xlib.h> 59#include <X11/Xatom.h> 60 61#if defined(__APPLE__) && defined(__MACH__) 62/* matches the re-define above */ 63#undef Cursor 64#endif 65 66/** These are the various supported subsystems under UNIX */ 67typedef enum { 68 SDL_SYSWM_X11 69} SDL_SYSWM_TYPE; 70 71/** The UNIX custom event structure */ 72struct SDL_SysWMmsg { 73 SDL_version version; 74 SDL_SYSWM_TYPE subsystem; 75 union { 76 XEvent xevent; 77 } event; 78}; 79 80/** The UNIX custom window manager information structure. 81 * When this structure is returned, it holds information about which 82 * low level system it is using, and will be one of SDL_SYSWM_TYPE. 83 */ 84typedef struct SDL_SysWMinfo { 85 SDL_version version; 86 SDL_SYSWM_TYPE subsystem; 87 union { 88 struct { 89 Display *display; /**< The X11 display */ 90 Window window; /**< The X11 display window */ 91 /** These locking functions should be called around 92 * any X11 functions using the display variable, 93 * but not the gfxdisplay variable. 94 * They lock the event thread, so should not be 95 * called around event functions or from event filters. 96 */ 97 /*@{*/ 98 void (*lock_func)(void); 99 void (*unlock_func)(void); 100 /*@}*/ 101 102 /** @name Introduced in SDL 1.0.2 */ 103 /*@{*/ 104 Window fswindow; /**< The X11 fullscreen window */ 105 Window wmwindow; /**< The X11 managed input window */ 106 /*@}*/ 107 108 /** @name Introduced in SDL 1.2.12 */ 109 /*@{*/ 110 Display *gfxdisplay; /**< The X11 display to which rendering is done */ 111 /*@}*/ 112 } x11; 113 } info; 114} SDL_SysWMinfo; 115 116#elif defined(SDL_VIDEO_DRIVER_NANOX) 117#include <microwin/nano-X.h> 118 119/** The generic custom event structure */ 120struct SDL_SysWMmsg { 121 SDL_version version; 122 int data; 123}; 124 125/** The windows custom window manager information structure */ 126typedef struct SDL_SysWMinfo { 127 SDL_version version ; 128 GR_WINDOW_ID window ; /* The display window */ 129} SDL_SysWMinfo; 130 131#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) 132#define WIN32_LEAN_AND_MEAN 133#include <windows.h> 134 135/** The windows custom event structure */ 136struct SDL_SysWMmsg { 137 SDL_version version; 138 HWND hwnd; /**< The window for the message */ 139 UINT msg; /**< The type of message */ 140 WPARAM wParam; /**< WORD message parameter */ 141 LPARAM lParam; /**< LONG message parameter */ 142}; 143 144/** The windows custom window manager information structure */ 145typedef struct SDL_SysWMinfo { 146 SDL_version version; 147 HWND window; /**< The Win32 display window */ 148 HGLRC hglrc; /**< The OpenGL context, if any */ 149} SDL_SysWMinfo; 150 151#elif defined(SDL_VIDEO_DRIVER_RISCOS) 152 153/** RISC OS custom event structure */ 154struct SDL_SysWMmsg { 155 SDL_version version; 156 int eventCode; /**< The window for the message */ 157 int pollBlock[64]; 158}; 159 160/** The RISC OS custom window manager information structure */ 161typedef struct SDL_SysWMinfo { 162 SDL_version version; 163 int wimpVersion; /**< Wimp version running under */ 164 int taskHandle; /**< The RISC OS task handle */ 165 int window; /**< The RISC OS display window */ 166} SDL_SysWMinfo; 167 168#elif defined(SDL_VIDEO_DRIVER_PHOTON) 169#include <sys/neutrino.h> 170#include <Ph.h> 171 172/** The QNX custom event structure */ 173struct SDL_SysWMmsg { 174 SDL_version version; 175 int data; 176}; 177 178/** The QNX custom window manager information structure */ 179typedef struct SDL_SysWMinfo { 180 SDL_version version; 181 int data; 182} SDL_SysWMinfo; 183 184#elif defined(SDL_VIDEO_DRIVER_QUARTZ) 185 186struct SDL_SysWMmsg { 187 SDL_version version; 188 int data; 189}; 190 191typedef struct SDL_SysWMinfo { 192 SDL_version version; 193 void* nsWindowPtr; 194} SDL_SysWMinfo; 195 196#else 197 198/** The generic custom event structure */ 199struct SDL_SysWMmsg { 200 SDL_version version; 201 int data; 202}; 203 204/** The generic custom window manager information structure */ 205typedef struct SDL_SysWMinfo { 206 SDL_version version; 207 int data; 208} SDL_SysWMinfo; 209 210#endif /* video driver type */ 211 212#endif /* SDL_PROTOTYPES_ONLY */ 213 214/* Function prototypes */ 215/** 216 * This function gives you custom hooks into the window manager information. 217 * It fills the structure pointed to by 'info' with custom information and 218 * returns 0 if the function is not implemented, 1 if the function is 219 * implemented and no error occurred, and -1 if the version member of 220 * the 'info' structure is not filled in or not supported. 221 * 222 * You typically use this function like this: 223 * @code 224 * SDL_SysWMinfo info; 225 * SDL_VERSION(&info.version); 226 * if ( SDL_GetWMInfo(&info) ) { ... } 227 * @endcode 228 */ 229extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); 230 231 232/* Ends C function definitions when using C++ */ 233#ifdef __cplusplus 234} 235#endif 236#include "close_code.h" 237 238#endif /* _SDL_syswm_h */ 239