include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 17 Jan 2011 09:09:15 -0800
changeset 5009 b21ad135d86b
parent 4903 f50c7996d925
child 5056 8b7988f42fcb
permissions -rw-r--r--
Minor documentation consistency cleanup
     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 #if defined(SDL_VIDEO_DRIVER_WIN32)
    58 #define WIN32_LEAN_AND_MEAN
    59 #include <windows.h>
    60 #endif
    61 
    62 /* This is the structure for custom window manager events */
    63 #if defined(SDL_VIDEO_DRIVER_X11)
    64 #if defined(__APPLE__) && defined(__MACH__)
    65 /* conflicts with Quickdraw.h */
    66 #define Cursor X11Cursor
    67 #endif
    68 
    69 #include <X11/Xlib.h>
    70 #include <X11/Xatom.h>
    71 
    72 #if defined(__APPLE__) && defined(__MACH__)
    73 /* matches the re-define above */
    74 #undef Cursor
    75 #endif
    76 
    77 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    78 
    79 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    80 #include <directfb/directfb.h>
    81 #endif
    82 
    83 #if defined(SDL_VIDEO_DRIVER_COCOA)
    84 #ifdef __OBJC__
    85 #include <Cocoa/Cocoa.h>
    86 #else
    87 typedef struct _NSWindow NSWindow;
    88 #endif
    89 #endif
    90 
    91 /** 
    92  *  These are the various supported windowing subsystems
    93  */
    94 typedef enum
    95 {
    96     SDL_SYSWM_UNKNOWN,
    97     SDL_SYSWM_WINDOWS,
    98     SDL_SYSWM_X11,
    99     SDL_SYSWM_DIRECTFB,
   100     SDL_SYSWM_COCOA,
   101 } SDL_SYSWM_TYPE;
   102 
   103 /**
   104  *  The custom event structure.
   105  */
   106 struct SDL_SysWMmsg
   107 {
   108     SDL_version version;
   109     SDL_SYSWM_TYPE subsystem;
   110     union
   111     {
   112 #if defined(SDL_VIDEO_DRIVER_WIN32)
   113         struct {
   114             HWND hwnd;                  /**< The window for the message */
   115             UINT msg;                   /**< The type of message */
   116             WPARAM wParam;              /**< WORD message parameter */
   117             LPARAM lParam;              /**< LONG message parameter */
   118         } win;
   119 #endif
   120 #if defined(SDL_VIDEO_DRIVER_X11)
   121         struct {
   122             XEvent event;
   123         } x11;
   124 #endif
   125 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   126         struct {
   127             DFBEvent event;
   128         } dfb;
   129 #endif
   130 #if defined(SDL_VIDEO_DRIVER_COCOA)
   131         struct
   132         {
   133             /* No Cocoa window events yet */
   134         } cocoa;
   135 #endif
   136     } /*msg*/;
   137 };
   138 
   139 /**
   140  *  The custom window manager information structure.
   141  *
   142  *  When this structure is returned, it holds information about which
   143  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   144  */
   145 struct SDL_SysWMinfo
   146 {
   147     SDL_version version;
   148     SDL_SYSWM_TYPE subsystem;
   149     union
   150     {
   151 #if defined(SDL_VIDEO_DRIVER_WIN32)
   152         struct
   153         {
   154             HWND window;                /**< The window handle */
   155         } win;
   156 #endif
   157 #if defined(SDL_VIDEO_DRIVER_X11)
   158         struct
   159         {
   160             Display *display;           /**< The X11 display */
   161             Window window;              /**< The X11 window */
   162         } x11;
   163 #endif
   164 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   165         struct
   166         {
   167             IDirectFB *dfb;             /**< The directfb main interface */
   168             IDirectFBWindow *window;    /**< The directfb window handle */
   169             IDirectFBSurface *surface;  /**< The directfb client surface */
   170         } dfb;
   171 #endif
   172 #if defined(SDL_VIDEO_DRIVER_COCOA)
   173         struct
   174         {
   175             NSWindow *window;           /* The Cocoa window */
   176         } cocoa;
   177 #endif
   178     } /*info*/;
   179 };
   180 
   181 #endif /* SDL_PROTOTYPES_ONLY */
   182 
   183 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   184 
   185 /* Function prototypes */
   186 /**
   187  *  \brief This function allows access to driver-dependent window information.
   188  *  
   189  *  \param window The window about which information is being requested
   190  *  \param info This structure must be initialized with the SDL version, and is 
   191  *              then filled in with information about the given window.
   192  *  
   193  *  \return SDL_TRUE if the function is implemented and the version member of 
   194  *          the \c info struct is valid, SDL_FALSE otherwise.
   195  *  
   196  *  You typically use this function like this:
   197  *  \code
   198  *  SDL_SysWMinfo info;
   199  *  SDL_VERSION(&info.version);
   200  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   201  *  \endcode
   202  */
   203 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   204                                                      SDL_SysWMinfo * info);
   205 
   206 
   207 /* Ends C function definitions when using C++ */
   208 #ifdef __cplusplus
   209 /* *INDENT-OFF* */
   210 }
   211 /* *INDENT-ON* */
   212 #endif
   213 #include "close_code.h"
   214 
   215 #endif /* _SDL_syswm_h */
   216 
   217 /* vi: set ts=4 sw=4 expandtab: */