include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 21 Jan 2010 06:21:52 +0000
changeset 3685 64ce267332c6
parent 3407 d3baf5ac4e37
child 3697 f7b03b6838cb
permissions -rw-r--r--
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 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 /**
    24  *  \file SDL_syswm.h
    25  *  
    26  *  Include file for SDL custom system window manager hooks.
    27  */
    28 
    29 #ifndef _SDL_syswm_h
    30 #define _SDL_syswm_h
    31 
    32 #include "SDL_stdinc.h"
    33 #include "SDL_error.h"
    34 #include "SDL_video.h"
    35 #include "SDL_version.h"
    36 
    37 #include "begin_code.h"
    38 /* Set up for C function definitions, even when using C++ */
    39 #ifdef __cplusplus
    40 /* *INDENT-OFF* */
    41 extern "C" {
    42 /* *INDENT-ON* */
    43 #endif
    44 
    45 /**
    46  *  \file SDL_syswm.h
    47  *  
    48  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
    49  *  which contains window-manager specific information and arrives whenever
    50  *  an unhandled window event occurs.  This event is ignored by default, but
    51  *  you can enable it with SDL_EventState().
    52  */
    53 #ifdef SDL_PROTOTYPES_ONLY
    54 struct SDL_SysWMinfo;
    55 #else
    56 
    57 /* This is the structure for custom window manager events */
    58 #if defined(SDL_VIDEO_DRIVER_X11)
    59 #if defined(__APPLE__) && defined(__MACH__)
    60 /* conflicts with Quickdraw.h */
    61 #define Cursor X11Cursor
    62 #endif
    63 
    64 #include <X11/Xlib.h>
    65 #include <X11/Xatom.h>
    66 
    67 #if defined(__APPLE__) && defined(__MACH__)
    68 /* matches the re-define above */
    69 #undef Cursor
    70 #endif
    71 
    72 /** 
    73  *  These are the various supported subsystems under UNIX.
    74  */
    75 typedef enum
    76 {
    77     SDL_SYSWM_X11
    78 } SDL_SYSWM_TYPE;
    79 
    80 /**
    81  *  The UNIX custom event structure.
    82  */
    83 struct SDL_SysWMmsg
    84 {
    85     SDL_version version;
    86     SDL_SYSWM_TYPE subsystem;
    87     union
    88     {
    89         XEvent xevent;
    90     } event;
    91 };
    92 
    93 /**
    94  *  The UNIX custom window manager information structure.
    95  *
    96  *  When this structure is returned, it holds information about which
    97  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
    98  */
    99 struct SDL_SysWMinfo
   100 {
   101     SDL_version version;
   102     SDL_SYSWM_TYPE subsystem;
   103     union
   104     {
   105         struct
   106         {
   107             Display *display;   /**< The X11 display */
   108             Window window;      /**< The X11 display window */
   109             /**
   110              *  These locking functions should be called around
   111              *  any X11 functions using the display variable.
   112              *  They lock the event thread, so should not be
   113              *  called around event functions or from event filters.
   114              */
   115             /*@{*/
   116             void (*lock_func) (void);
   117             void (*unlock_func) (void);
   118             /*@}*/
   119 
   120             /**
   121              *  Introduced in SDL 1.0.2.
   122              */
   123             /*@{*/
   124             Window fswindow;    /**< The X11 fullscreen window */
   125             Window wmwindow;    /**< The X11 managed input window */
   126             /*@}*/
   127         } x11;
   128     } info;
   129 };
   130 
   131 #elif defined(SDL_VIDEO_DRIVER_WIN32)
   132 #define WIN32_LEAN_AND_MEAN
   133 #include <windows.h>
   134 
   135 /**
   136  *  The windows custom event structure.
   137  */
   138 struct SDL_SysWMmsg
   139 {
   140     SDL_version version;
   141     HWND hwnd;                  /**< The window for the message */
   142     UINT msg;                   /**< The type of message */
   143     WPARAM wParam;              /**< WORD message parameter */
   144     LPARAM lParam;              /**< LONG message parameter */
   145 };
   146 
   147 /**
   148  *  The windows custom window manager information structure.
   149  */
   150 struct SDL_SysWMinfo
   151 {
   152     SDL_version version;
   153     HWND window;                /**< The Win32 display window */
   154 };
   155 
   156 #elif defined(SDL_VIDEO_DRIVER_RISCOS)
   157 
   158 /**
   159  *  RISC OS custom event structure.
   160  */
   161 struct SDL_SysWMmsg
   162 {
   163     SDL_version version;
   164     int eventCode;              /**< The window for the message */
   165     int pollBlock[64];
   166 };
   167 
   168 /**
   169  *  The RISC OS custom window manager information structure.
   170  */
   171 struct SDL_SysWMinfo
   172 {
   173     SDL_version version;
   174     int wimpVersion;            /**< Wimp version running under */
   175     int taskHandle;             /**< The RISC OS task handle */
   176     int window;                 /**< The RISC OS display window */
   177 };
   178 
   179 #elif defined(SDL_VIDEO_DRIVER_PHOTON) || defined(SDL_VIDEO_DRIVER_QNXGF)
   180 #include <sys/neutrino.h>
   181 #if defined(SDL_VIDEO_OPENGL_ES)
   182 #include <gf/gf.h>
   183 #endif /* SDL_VIDEO_OPENGL_ES */
   184 #include <Ph.h>
   185 
   186 /**
   187  * The QNX custom event structure.
   188  */
   189 struct SDL_SysWMmsg
   190 {
   191     SDL_version version;
   192     int data;
   193 };
   194 
   195 /**
   196  *  The QNX Photon custom window manager information structure.
   197  */
   198 struct SDL_SysWMinfo
   199 {
   200     SDL_version version;
   201     int data;
   202 };
   203 
   204 #else
   205 
   206 /**
   207  *  The generic custom event structure.
   208  */
   209 struct SDL_SysWMmsg
   210 {
   211     SDL_version version;
   212     int data;
   213 };
   214 
   215 /**
   216  *  The generic custom window manager information structure.
   217  */
   218 struct SDL_SysWMinfo
   219 {
   220     SDL_version version;
   221     int data;
   222 };
   223 
   224 #endif /* video driver type */
   225 
   226 #endif /* SDL_PROTOTYPES_ONLY */
   227 
   228 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   229 
   230 /* Function prototypes */
   231 /**
   232  *  \brief This function allows access to driver-dependent window information.
   233  *  
   234  *  \param windowID The window about which information is being requested
   235  *  \param info This structure must be initialized with the SDL version, and is 
   236  *              then filled in with information about the given window.
   237  *  
   238  *  \return SDL_TRUE if the function is implemented and the version member of 
   239  *          the \c info struct is valid, SDL_FALSE otherwise.
   240  *  
   241  *  You typically use this function like this:
   242  *  \code
   243  *  SDL_SysWMInfo info;
   244  *  SDL_VERSION(&info.version);
   245  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   246  *  \endcode
   247  */
   248 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   249                                                      SDL_SysWMinfo * info);
   250 
   251 
   252 /* Ends C function definitions when using C++ */
   253 #ifdef __cplusplus
   254 /* *INDENT-OFF* */
   255 }
   256 /* *INDENT-ON* */
   257 #endif
   258 #include "close_code.h"
   259 
   260 #endif /* _SDL_syswm_h */
   261 
   262 /* vi: set ts=4 sw=4 expandtab: */