include/SDL_syswm.h
author David Ludwig <dludwig@pobox.com>
Mon, 01 Apr 2013 21:33:06 -0400
changeset 8453 499aa167ea79
parent 8439 14d94a8a9fb6
child 8463 98dbf81ed5e9
permissions -rw-r--r--
WinRT: made WinRT path retrieval be available in both UCS-2 and UTF-8 flavors
     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 /* 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_WINDOWSRT,
   107     SDL_SYSWM_X11,
   108     SDL_SYSWM_DIRECTFB,
   109     SDL_SYSWM_COCOA,
   110     SDL_SYSWM_UIKIT,
   111 } SDL_SYSWM_TYPE;
   112 
   113 /**
   114  *  The custom event structure.
   115  */
   116 struct SDL_SysWMmsg
   117 {
   118     SDL_version version;
   119     SDL_SYSWM_TYPE subsystem;
   120     union
   121     {
   122 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   123         struct {
   124             HWND hwnd;                  /**< The window for the message */
   125             UINT msg;                   /**< The type of message */
   126             WPARAM wParam;              /**< WORD message parameter */
   127             LPARAM lParam;              /**< LONG message parameter */
   128         } win;
   129 #endif
   130 #if defined(SDL_VIDEO_DRIVER_X11)
   131         struct {
   132             XEvent event;
   133         } x11;
   134 #endif
   135 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   136         struct {
   137             DFBEvent event;
   138         } dfb;
   139 #endif
   140 #if defined(SDL_VIDEO_DRIVER_COCOA)
   141         struct
   142         {
   143             /* No Cocoa window events yet */
   144         } cocoa;
   145 #endif
   146 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   147         struct
   148         {
   149             /* No UIKit window events yet */
   150         } uikit;
   151 #endif
   152         /* Can't have an empty union */
   153         int dummy;
   154     } msg;
   155 };
   156 
   157 /**
   158  *  The custom window manager information structure.
   159  *
   160  *  When this structure is returned, it holds information about which
   161  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   162  */
   163 struct SDL_SysWMinfo
   164 {
   165     SDL_version version;
   166     SDL_SYSWM_TYPE subsystem;
   167     union
   168     {
   169 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   170         struct
   171         {
   172             HWND window;                /**< The window handle */
   173         } win;
   174 #endif
   175 #if defined(SDL_VIDEO_DRIVER_WINRT)
   176         struct
   177         {
   178             void * window;          /**< The Windows RT CoreWindow, casted from 'CoreWindow ^*' to 'void *' */
   179         } winrt;
   180 #endif
   181 #if defined(SDL_VIDEO_DRIVER_X11)
   182         struct
   183         {
   184             Display *display;           /**< The X11 display */
   185             Window window;              /**< The X11 window */
   186         } x11;
   187 #endif
   188 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   189         struct
   190         {
   191             IDirectFB *dfb;             /**< The directfb main interface */
   192             IDirectFBWindow *window;    /**< The directfb window handle */
   193             IDirectFBSurface *surface;  /**< The directfb client surface */
   194         } dfb;
   195 #endif
   196 #if defined(SDL_VIDEO_DRIVER_COCOA)
   197         struct
   198         {
   199             NSWindow *window;           /* The Cocoa window */
   200         } cocoa;
   201 #endif
   202 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   203         struct
   204         {
   205             UIWindow *window;           /* The UIKit window */
   206             UIViewController *viewcontroller;   /* The UIKit view controller */
   207         } uikit;
   208 #endif
   209         /* Can't have an empty union */
   210         int dummy;
   211     } info;
   212 };
   213 
   214 #endif /* SDL_PROTOTYPES_ONLY */
   215 
   216 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   217 
   218 /* Function prototypes */
   219 /**
   220  *  \brief This function allows access to driver-dependent window information.
   221  *  
   222  *  \param window The window about which information is being requested
   223  *  \param info This structure must be initialized with the SDL version, and is 
   224  *              then filled in with information about the given window.
   225  *  
   226  *  \return SDL_TRUE if the function is implemented and the version member of 
   227  *          the \c info struct is valid, SDL_FALSE otherwise.
   228  *  
   229  *  You typically use this function like this:
   230  *  \code
   231  *  SDL_SysWMinfo info;
   232  *  SDL_VERSION(&info.version);
   233  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   234  *  \endcode
   235  */
   236 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   237                                                      SDL_SysWMinfo * info);
   238 
   239 
   240 /* Ends C function definitions when using C++ */
   241 #ifdef __cplusplus
   242 /* *INDENT-OFF* */
   243 }
   244 /* *INDENT-ON* */
   245 #endif
   246 #include "close_code.h"
   247 
   248 #endif /* _SDL_syswm_h */
   249 
   250 /* vi: set ts=4 sw=4 expandtab: */