include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 12 Jul 2010 01:20:57 -0700
changeset 4510 6f8175ad0335
parent 3697 f7b03b6838cb
child 4530 4069c65b01f2
permissions -rw-r--r--
Implemented X11 system window manager info for SDL 1.3. It's simple. Really.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 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         } x11;
   110     } info;
   111 };
   112 
   113 #elif defined(SDL_VIDEO_DRIVER_WIN32)
   114 #define WIN32_LEAN_AND_MEAN
   115 #include <windows.h>
   116 
   117 /**
   118  *  The windows custom event structure.
   119  */
   120 struct SDL_SysWMmsg
   121 {
   122     SDL_version version;
   123     HWND hwnd;                  /**< The window for the message */
   124     UINT msg;                   /**< The type of message */
   125     WPARAM wParam;              /**< WORD message parameter */
   126     LPARAM lParam;              /**< LONG message parameter */
   127 };
   128 
   129 /**
   130  *  The windows custom window manager information structure.
   131  */
   132 struct SDL_SysWMinfo
   133 {
   134     SDL_version version;
   135     HWND window;                /**< The Win32 display window */
   136 };
   137 
   138 #elif defined(SDL_VIDEO_DRIVER_RISCOS)
   139 
   140 /**
   141  *  RISC OS custom event structure.
   142  */
   143 struct SDL_SysWMmsg
   144 {
   145     SDL_version version;
   146     int eventCode;              /**< The window for the message */
   147     int pollBlock[64];
   148 };
   149 
   150 /**
   151  *  The RISC OS custom window manager information structure.
   152  */
   153 struct SDL_SysWMinfo
   154 {
   155     SDL_version version;
   156     int wimpVersion;            /**< Wimp version running under */
   157     int taskHandle;             /**< The RISC OS task handle */
   158     int window;                 /**< The RISC OS display window */
   159 };
   160 
   161 #elif defined(SDL_VIDEO_DRIVER_PHOTON) || defined(SDL_VIDEO_DRIVER_QNXGF)
   162 #include <sys/neutrino.h>
   163 #if defined(SDL_VIDEO_OPENGL_ES)
   164 #include <gf/gf.h>
   165 #endif /* SDL_VIDEO_OPENGL_ES */
   166 #include <Ph.h>
   167 
   168 /**
   169  * The QNX custom event structure.
   170  */
   171 struct SDL_SysWMmsg
   172 {
   173     SDL_version version;
   174     int data;
   175 };
   176 
   177 /**
   178  *  The QNX Photon custom window manager information structure.
   179  */
   180 struct SDL_SysWMinfo
   181 {
   182     SDL_version version;
   183     int data;
   184 };
   185 
   186 #else
   187 
   188 /**
   189  *  The generic custom event structure.
   190  */
   191 struct SDL_SysWMmsg
   192 {
   193     SDL_version version;
   194     int data;
   195 };
   196 
   197 /**
   198  *  The generic custom window manager information structure.
   199  */
   200 struct SDL_SysWMinfo
   201 {
   202     SDL_version version;
   203     int data;
   204 };
   205 
   206 #endif /* video driver type */
   207 
   208 #endif /* SDL_PROTOTYPES_ONLY */
   209 
   210 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   211 
   212 /* Function prototypes */
   213 /**
   214  *  \brief This function allows access to driver-dependent window information.
   215  *  
   216  *  \param windowID The window about which information is being requested
   217  *  \param info This structure must be initialized with the SDL version, and is 
   218  *              then filled in with information about the given window.
   219  *  
   220  *  \return SDL_TRUE if the function is implemented and the version member of 
   221  *          the \c info struct is valid, SDL_FALSE otherwise.
   222  *  
   223  *  You typically use this function like this:
   224  *  \code
   225  *  SDL_SysWMInfo info;
   226  *  SDL_VERSION(&info.version);
   227  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   228  *  \endcode
   229  */
   230 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   231                                                      SDL_SysWMinfo * info);
   232 
   233 
   234 /* Ends C function definitions when using C++ */
   235 #ifdef __cplusplus
   236 /* *INDENT-OFF* */
   237 }
   238 /* *INDENT-ON* */
   239 #endif
   240 #include "close_code.h"
   241 
   242 #endif /* _SDL_syswm_h */
   243 
   244 /* vi: set ts=4 sw=4 expandtab: */