include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 20 Jan 2011 18:09:55 -0800
changeset 5063 5680976fb37a
parent 5062 e8916fe9cfc8
child 5065 7e4c7790700e
permissions -rw-r--r--
You can't have an empty union in the structure...
     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_WINDOWS)
    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 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    92 #ifdef __OBJC__
    93 #include <UIKit/UIKit.h>
    94 #else
    95 typedef struct _UIWindow UIWindow;
    96 #endif
    97 #endif
    98 
    99 /** 
   100  *  These are the various supported windowing subsystems
   101  */
   102 typedef enum
   103 {
   104     SDL_SYSWM_UNKNOWN,
   105     SDL_SYSWM_WINDOWS,
   106     SDL_SYSWM_X11,
   107     SDL_SYSWM_DIRECTFB,
   108     SDL_SYSWM_COCOA,
   109     SDL_SYSWM_UIKIT,
   110 } SDL_SYSWM_TYPE;
   111 
   112 /**
   113  *  The custom event structure.
   114  */
   115 struct SDL_SysWMmsg
   116 {
   117     SDL_version version;
   118     SDL_SYSWM_TYPE subsystem;
   119     union
   120     {
   121 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   122         struct {
   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         } win;
   128 #elif defined(SDL_VIDEO_DRIVER_X11)
   129         struct {
   130             XEvent event;
   131         } x11;
   132 #elif defined(SDL_VIDEO_DRIVER_DIRECTFB)
   133         struct {
   134             DFBEvent event;
   135         } dfb;
   136 #elif defined(SDL_VIDEO_DRIVER_COCOA)
   137         struct
   138         {
   139             /* No Cocoa window events yet */
   140         } cocoa;
   141 #elif defined(SDL_VIDEO_DRIVER_UIKIT)
   142         struct
   143         {
   144             /* No UIKit window events yet */
   145         } uikit;
   146 else
   147         /* Can't have an empty union */
   148         int dummy;
   149 #endif
   150     } msg;
   151 };
   152 
   153 /**
   154  *  The custom window manager information structure.
   155  *
   156  *  When this structure is returned, it holds information about which
   157  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   158  */
   159 struct SDL_SysWMinfo
   160 {
   161     SDL_version version;
   162     SDL_SYSWM_TYPE subsystem;
   163     union
   164     {
   165 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   166         struct
   167         {
   168             HWND window;                /**< The window handle */
   169         } win;
   170 #elif defined(SDL_VIDEO_DRIVER_X11)
   171         struct
   172         {
   173             Display *display;           /**< The X11 display */
   174             Window window;              /**< The X11 window */
   175         } x11;
   176 #elif defined(SDL_VIDEO_DRIVER_DIRECTFB)
   177         struct
   178         {
   179             IDirectFB *dfb;             /**< The directfb main interface */
   180             IDirectFBWindow *window;    /**< The directfb window handle */
   181             IDirectFBSurface *surface;  /**< The directfb client surface */
   182         } dfb;
   183 #elif defined(SDL_VIDEO_DRIVER_COCOA)
   184         struct
   185         {
   186             NSWindow *window;           /* The Cocoa window */
   187         } cocoa;
   188 #elif defined(SDL_VIDEO_DRIVER_UIKIT)
   189         struct
   190         {
   191             UIWindow *window;           /* The UIKit window */
   192         } uikit;
   193 #else
   194         /* Can't have an empty union */
   195         int dummy;
   196 #endif
   197     } info;
   198 };
   199 
   200 #endif /* SDL_PROTOTYPES_ONLY */
   201 
   202 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   203 
   204 /* Function prototypes */
   205 /**
   206  *  \brief This function allows access to driver-dependent window information.
   207  *  
   208  *  \param window The window about which information is being requested
   209  *  \param info This structure must be initialized with the SDL version, and is 
   210  *              then filled in with information about the given window.
   211  *  
   212  *  \return SDL_TRUE if the function is implemented and the version member of 
   213  *          the \c info struct is valid, SDL_FALSE otherwise.
   214  *  
   215  *  You typically use this function like this:
   216  *  \code
   217  *  SDL_SysWMinfo info;
   218  *  SDL_VERSION(&info.version);
   219  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   220  *  \endcode
   221  */
   222 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   223                                                      SDL_SysWMinfo * info);
   224 
   225 
   226 /* Ends C function definitions when using C++ */
   227 #ifdef __cplusplus
   228 /* *INDENT-OFF* */
   229 }
   230 /* *INDENT-ON* */
   231 #endif
   232 #include "close_code.h"
   233 
   234 #endif /* _SDL_syswm_h */
   235 
   236 /* vi: set ts=4 sw=4 expandtab: */