include/SDL_syswm.h
author David Ludwig <dludwig@pobox.com>
Wed, 18 Jul 2012 22:26:47 -0400
changeset 8305 3d522e6d4ae1
parent 6138 4c64952a58fb
child 8411 aca0591bc58f
permissions -rw-r--r--
added UIViewController pointer to SDL_SysWMinfo for iOS
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 /**
    23  *  \file SDL_syswm.h
    24  *  
    25  *  Include file for SDL custom system window manager hooks.
    26  */
    27 
    28 #ifndef _SDL_syswm_h
    29 #define _SDL_syswm_h
    30 
    31 #include "SDL_stdinc.h"
    32 #include "SDL_error.h"
    33 #include "SDL_video.h"
    34 #include "SDL_version.h"
    35 
    36 #include "begin_code.h"
    37 /* Set up for C function definitions, even when using C++ */
    38 #ifdef __cplusplus
    39 /* *INDENT-OFF* */
    40 extern "C" {
    41 /* *INDENT-ON* */
    42 #endif
    43 
    44 /**
    45  *  \file SDL_syswm.h
    46  *  
    47  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
    48  *  which contains window-manager specific information and arrives whenever
    49  *  an unhandled window event occurs.  This event is ignored by default, but
    50  *  you can enable it with SDL_EventState().
    51  */
    52 #ifdef SDL_PROTOTYPES_ONLY
    53 struct SDL_SysWMinfo;
    54 #else
    55 
    56 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    57 #define WIN32_LEAN_AND_MEAN
    58 #include <windows.h>
    59 #endif
    60 
    61 /* This is the structure for custom window manager events */
    62 #if defined(SDL_VIDEO_DRIVER_X11)
    63 #if defined(__APPLE__) && defined(__MACH__)
    64 /* conflicts with Quickdraw.h */
    65 #define Cursor X11Cursor
    66 #endif
    67 
    68 #include <X11/Xlib.h>
    69 #include <X11/Xatom.h>
    70 
    71 #if defined(__APPLE__) && defined(__MACH__)
    72 /* matches the re-define above */
    73 #undef Cursor
    74 #endif
    75 
    76 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    77 
    78 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    79 #include <directfb.h>
    80 #endif
    81 
    82 #if defined(SDL_VIDEO_DRIVER_COCOA)
    83 #ifdef __OBJC__
    84 #include <Cocoa/Cocoa.h>
    85 #else
    86 typedef struct _NSWindow NSWindow;
    87 #endif
    88 #endif
    89 
    90 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    91 #ifdef __OBJC__
    92 #include <UIKit/UIKit.h>
    93 #else
    94 typedef struct _UIWindow UIWindow;
    95 typedef struct _UIViewController UIViewController;
    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 #endif
   129 #if defined(SDL_VIDEO_DRIVER_X11)
   130         struct {
   131             XEvent event;
   132         } x11;
   133 #endif
   134 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   135         struct {
   136             DFBEvent event;
   137         } dfb;
   138 #endif
   139 #if defined(SDL_VIDEO_DRIVER_COCOA)
   140         struct
   141         {
   142             /* No Cocoa window events yet */
   143         } cocoa;
   144 #endif
   145 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   146         struct
   147         {
   148             /* No UIKit window events yet */
   149         } uikit;
   150 #endif
   151         /* Can't have an empty union */
   152         int dummy;
   153     } msg;
   154 };
   155 
   156 /**
   157  *  The custom window manager information structure.
   158  *
   159  *  When this structure is returned, it holds information about which
   160  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   161  */
   162 struct SDL_SysWMinfo
   163 {
   164     SDL_version version;
   165     SDL_SYSWM_TYPE subsystem;
   166     union
   167     {
   168 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   169         struct
   170         {
   171             HWND window;                /**< The window handle */
   172         } win;
   173 #endif
   174 #if defined(SDL_VIDEO_DRIVER_X11)
   175         struct
   176         {
   177             Display *display;           /**< The X11 display */
   178             Window window;              /**< The X11 window */
   179         } x11;
   180 #endif
   181 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   182         struct
   183         {
   184             IDirectFB *dfb;             /**< The directfb main interface */
   185             IDirectFBWindow *window;    /**< The directfb window handle */
   186             IDirectFBSurface *surface;  /**< The directfb client surface */
   187         } dfb;
   188 #endif
   189 #if defined(SDL_VIDEO_DRIVER_COCOA)
   190         struct
   191         {
   192             NSWindow *window;           /* The Cocoa window */
   193         } cocoa;
   194 #endif
   195 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   196         struct
   197         {
   198             UIWindow *window;           /* The UIKit window */
   199             UIViewController *viewcontroller;   /* The UIKit view controller */
   200         } uikit;
   201 #endif
   202         /* Can't have an empty union */
   203         int dummy;
   204     } info;
   205 };
   206 
   207 #endif /* SDL_PROTOTYPES_ONLY */
   208 
   209 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   210 
   211 /* Function prototypes */
   212 /**
   213  *  \brief This function allows access to driver-dependent window information.
   214  *  
   215  *  \param window The window about which information is being requested
   216  *  \param info This structure must be initialized with the SDL version, and is 
   217  *              then filled in with information about the given window.
   218  *  
   219  *  \return SDL_TRUE if the function is implemented and the version member of 
   220  *          the \c info struct is valid, SDL_FALSE otherwise.
   221  *  
   222  *  You typically use this function like this:
   223  *  \code
   224  *  SDL_SysWMinfo info;
   225  *  SDL_VERSION(&info.version);
   226  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   227  *  \endcode
   228  */
   229 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   230                                                      SDL_SysWMinfo * info);
   231 
   232 
   233 /* Ends C function definitions when using C++ */
   234 #ifdef __cplusplus
   235 /* *INDENT-OFF* */
   236 }
   237 /* *INDENT-ON* */
   238 #endif
   239 #include "close_code.h"
   240 
   241 #endif /* _SDL_syswm_h */
   242 
   243 /* vi: set ts=4 sw=4 expandtab: */