include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 27 Sep 2010 00:50:46 -0700
changeset 4899 5d529386db73
parent 4895 fd27410a5db0
child 4900 69d9db65f248
permissions -rw-r--r--
attached is a patch to support DirectFB in include/SDL_syswm.h. It
defines SDL_SYSWM_DIRECTFB as a subsystem.
This allows developers to e.g. access DirectFB's video and picture
providers.

Kind regards,

André
     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) || defined(SDL_VIDEO_DRIVER_DIRECTFB)
    59 #if defined(SDL_VIDEO_DRIVER_X11)
    60 #if defined(__APPLE__) && defined(__MACH__)
    61 /* conflicts with Quickdraw.h */
    62 #define Cursor X11Cursor
    63 #endif
    64 
    65 #include <X11/Xlib.h>
    66 #include <X11/Xatom.h>
    67 
    68 #if defined(__APPLE__) && defined(__MACH__)
    69 /* matches the re-define above */
    70 #undef Cursor
    71 #endif
    72 
    73 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    74 
    75 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    76 #include <directfb/directfb.h>
    77 #endif
    78 /** 
    79  *  These are the various supported subsystems under UNIX.
    80  */
    81 typedef enum
    82 {
    83 #if defined(SDL_VIDEO_DRIVER_X11)
    84     SDL_SYSWM_X11,
    85 #endif
    86 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    87     SDL_SYSWM_DIRECTFB,
    88 #endif
    89 } SDL_SYSWM_TYPE;
    90 
    91 /**
    92  *  The UNIX custom event structure.
    93  */
    94 struct SDL_SysWMmsg
    95 {
    96     SDL_version version;
    97     SDL_SYSWM_TYPE subsystem;
    98     union
    99     {
   100 #if defined(SDL_VIDEO_DRIVER_X11)
   101         XEvent xevent;
   102 #endif
   103 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   104         DFBEvent dfb_event;
   105 #endif
   106     } event;
   107 };
   108 
   109 /**
   110  *  The UNIX custom window manager information structure.
   111  *
   112  *  When this structure is returned, it holds information about which
   113  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   114  */
   115 struct SDL_SysWMinfo
   116 {
   117     SDL_version version;
   118     SDL_SYSWM_TYPE subsystem;
   119     union
   120     {
   121 #if defined(SDL_VIDEO_DRIVER_X11)
   122         struct
   123         {
   124             Display *display;   /**< The X11 display */
   125             Window window;      /**< The X11 display window */
   126         } x11;
   127 #endif
   128 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   129         struct
   130         {
   131         	IDirectFB *dfb;   			/**< The directfb main interface */
   132         	IDirectFBWindow *window;    /**< The directfb window handle */
   133         	IDirectFBSurface *surface;  /**< The directfb client surface */
   134         } directfb;
   135 #endif
   136     } info;
   137 };
   138 
   139 #elif defined(SDL_VIDEO_DRIVER_WIN32)
   140 #define WIN32_LEAN_AND_MEAN
   141 #include <windows.h>
   142 
   143 /**
   144  *  The windows custom event structure.
   145  */
   146 struct SDL_SysWMmsg
   147 {
   148     SDL_version version;
   149     HWND hwnd;                  /**< The window for the message */
   150     UINT msg;                   /**< The type of message */
   151     WPARAM wParam;              /**< WORD message parameter */
   152     LPARAM lParam;              /**< LONG message parameter */
   153 };
   154 
   155 /**
   156  *  The windows custom window manager information structure.
   157  */
   158 struct SDL_SysWMinfo
   159 {
   160     SDL_version version;
   161     HWND window;                /**< The Win32 display window */
   162 };
   163 
   164 #elif defined(SDL_VIDEO_DRIVER_RISCOS)
   165 
   166 /**
   167  *  RISC OS custom event structure.
   168  */
   169 struct SDL_SysWMmsg
   170 {
   171     SDL_version version;
   172     int eventCode;              /**< The window for the message */
   173     int pollBlock[64];
   174 };
   175 
   176 /**
   177  *  The RISC OS custom window manager information structure.
   178  */
   179 struct SDL_SysWMinfo
   180 {
   181     SDL_version version;
   182     int wimpVersion;            /**< Wimp version running under */
   183     int taskHandle;             /**< The RISC OS task handle */
   184     int window;                 /**< The RISC OS display window */
   185 };
   186 
   187 #elif defined(SDL_VIDEO_DRIVER_PHOTON) || defined(SDL_VIDEO_DRIVER_QNXGF)
   188 #include <sys/neutrino.h>
   189 #if defined(SDL_VIDEO_OPENGL_ES)
   190 #include <gf/gf.h>
   191 #endif /* SDL_VIDEO_OPENGL_ES */
   192 #include <Ph.h>
   193 
   194 /**
   195  * The QNX custom event structure.
   196  */
   197 struct SDL_SysWMmsg
   198 {
   199     SDL_version version;
   200     int data;
   201 };
   202 
   203 /**
   204  *  The QNX Photon custom window manager information structure.
   205  */
   206 struct SDL_SysWMinfo
   207 {
   208     SDL_version version;
   209     int data;
   210 };
   211 
   212 #else
   213 
   214 /**
   215  *  The generic custom event structure.
   216  */
   217 struct SDL_SysWMmsg
   218 {
   219     SDL_version version;
   220     int data;
   221 };
   222 
   223 /**
   224  *  The generic custom window manager information structure.
   225  */
   226 struct SDL_SysWMinfo
   227 {
   228     SDL_version version;
   229     int data;
   230 };
   231 
   232 #endif /* video driver type */
   233 
   234 #endif /* SDL_PROTOTYPES_ONLY */
   235 
   236 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   237 
   238 /* Function prototypes */
   239 /**
   240  *  \brief This function allows access to driver-dependent window information.
   241  *  
   242  *  \param window The window about which information is being requested
   243  *  \param info This structure must be initialized with the SDL version, and is 
   244  *              then filled in with information about the given window.
   245  *  
   246  *  \return SDL_TRUE if the function is implemented and the version member of 
   247  *          the \c info struct is valid, SDL_FALSE otherwise.
   248  *  
   249  *  You typically use this function like this:
   250  *  \code
   251  *  SDL_SysWMinfo info;
   252  *  SDL_VERSION(&info.version);
   253  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   254  *  \endcode
   255  */
   256 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   257                                                      SDL_SysWMinfo * info);
   258 
   259 
   260 /* Ends C function definitions when using C++ */
   261 #ifdef __cplusplus
   262 /* *INDENT-OFF* */
   263 }
   264 /* *INDENT-ON* */
   265 #endif
   266 #include "close_code.h"
   267 
   268 #endif /* _SDL_syswm_h */
   269 
   270 /* vi: set ts=4 sw=4 expandtab: */