include/SDL_syswm.h
author David Ludwig <dludwig@pobox.com>
Tue, 16 Apr 2013 23:40:03 -0400
changeset 8463 98dbf81ed5e9
parent 8439 14d94a8a9fb6
child 8477 ad08f0d710f3
permissions -rw-r--r--
WinRT: made SDL's inner WinRT CoreWindow be accessible to non-C++/CX code, in theory
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 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 #if defined(SDL_VIDEO_DRIVER_WINRT)
    62 #include <Unknwn.h>
    63 #endif
    64 
    65 /* This is the structure for custom window manager events */
    66 #if defined(SDL_VIDEO_DRIVER_X11)
    67 #if defined(__APPLE__) && defined(__MACH__)
    68 /* conflicts with Quickdraw.h */
    69 #define Cursor X11Cursor
    70 #endif
    71 
    72 #include <X11/Xlib.h>
    73 #include <X11/Xatom.h>
    74 
    75 #if defined(__APPLE__) && defined(__MACH__)
    76 /* matches the re-define above */
    77 #undef Cursor
    78 #endif
    79 
    80 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    81 
    82 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    83 #include <directfb.h>
    84 #endif
    85 
    86 #if defined(SDL_VIDEO_DRIVER_COCOA)
    87 #ifdef __OBJC__
    88 #include <Cocoa/Cocoa.h>
    89 #else
    90 typedef struct _NSWindow NSWindow;
    91 #endif
    92 #endif
    93 
    94 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    95 #ifdef __OBJC__
    96 #include <UIKit/UIKit.h>
    97 #else
    98 typedef struct _UIWindow UIWindow;
    99 typedef struct _UIViewController UIViewController;
   100 #endif
   101 #endif
   102 
   103 /** 
   104  *  These are the various supported windowing subsystems
   105  */
   106 typedef enum
   107 {
   108     SDL_SYSWM_UNKNOWN,
   109     SDL_SYSWM_WINDOWS,
   110     SDL_SYSWM_WINDOWSRT,
   111     SDL_SYSWM_X11,
   112     SDL_SYSWM_DIRECTFB,
   113     SDL_SYSWM_COCOA,
   114     SDL_SYSWM_UIKIT,
   115 } SDL_SYSWM_TYPE;
   116 
   117 /**
   118  *  The custom event structure.
   119  */
   120 struct SDL_SysWMmsg
   121 {
   122     SDL_version version;
   123     SDL_SYSWM_TYPE subsystem;
   124     union
   125     {
   126 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   127         struct {
   128             HWND hwnd;                  /**< The window for the message */
   129             UINT msg;                   /**< The type of message */
   130             WPARAM wParam;              /**< WORD message parameter */
   131             LPARAM lParam;              /**< LONG message parameter */
   132         } win;
   133 #endif
   134 #if defined(SDL_VIDEO_DRIVER_X11)
   135         struct {
   136             XEvent event;
   137         } x11;
   138 #endif
   139 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   140         struct {
   141             DFBEvent event;
   142         } dfb;
   143 #endif
   144 #if defined(SDL_VIDEO_DRIVER_COCOA)
   145         struct
   146         {
   147             /* No Cocoa window events yet */
   148         } cocoa;
   149 #endif
   150 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   151         struct
   152         {
   153             /* No UIKit window events yet */
   154         } uikit;
   155 #endif
   156         /* Can't have an empty union */
   157         int dummy;
   158     } msg;
   159 };
   160 
   161 /**
   162  *  The custom window manager information structure.
   163  *
   164  *  When this structure is returned, it holds information about which
   165  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   166  */
   167 struct SDL_SysWMinfo
   168 {
   169     SDL_version version;
   170     SDL_SYSWM_TYPE subsystem;
   171     union
   172     {
   173 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   174         struct
   175         {
   176             HWND window;                /**< The window handle */
   177         } win;
   178 #endif
   179 #if defined(SDL_VIDEO_DRIVER_WINRT)
   180         struct
   181         {
   182             IUnknown * window;          /**< The Windows RT CoreWindow */
   183         } winrt;
   184 #endif
   185 #if defined(SDL_VIDEO_DRIVER_X11)
   186         struct
   187         {
   188             Display *display;           /**< The X11 display */
   189             Window window;              /**< The X11 window */
   190         } x11;
   191 #endif
   192 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   193         struct
   194         {
   195             IDirectFB *dfb;             /**< The directfb main interface */
   196             IDirectFBWindow *window;    /**< The directfb window handle */
   197             IDirectFBSurface *surface;  /**< The directfb client surface */
   198         } dfb;
   199 #endif
   200 #if defined(SDL_VIDEO_DRIVER_COCOA)
   201         struct
   202         {
   203             NSWindow *window;           /* The Cocoa window */
   204         } cocoa;
   205 #endif
   206 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   207         struct
   208         {
   209             UIWindow *window;           /* The UIKit window */
   210             UIViewController *viewcontroller;   /* The UIKit view controller */
   211         } uikit;
   212 #endif
   213         /* Can't have an empty union */
   214         int dummy;
   215     } info;
   216 };
   217 
   218 #endif /* SDL_PROTOTYPES_ONLY */
   219 
   220 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   221 
   222 /* Function prototypes */
   223 /**
   224  *  \brief This function allows access to driver-dependent window information.
   225  *  
   226  *  \param window The window about which information is being requested
   227  *  \param info This structure must be initialized with the SDL version, and is 
   228  *              then filled in with information about the given window.
   229  *  
   230  *  \return SDL_TRUE if the function is implemented and the version member of 
   231  *          the \c info struct is valid, SDL_FALSE otherwise.
   232  *  
   233  *  You typically use this function like this:
   234  *  \code
   235  *  SDL_SysWMinfo info;
   236  *  SDL_VERSION(&info.version);
   237  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   238  *  \endcode
   239  */
   240 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   241                                                      SDL_SysWMinfo * info);
   242 
   243 
   244 /* Ends C function definitions when using C++ */
   245 #ifdef __cplusplus
   246 /* *INDENT-OFF* */
   247 }
   248 /* *INDENT-ON* */
   249 #endif
   250 #include "close_code.h"
   251 
   252 #endif /* _SDL_syswm_h */
   253 
   254 /* vi: set ts=4 sw=4 expandtab: */