include/SDL_syswm.h
author Jørgen P. Tjernø <jorgen@uberent.com>
Wed, 04 Jun 2014 10:33:23 -0700
changeset 8812 b0f96c169c97
parent 8799 e2fd743d84ea
child 8968 47decd0106f8
permissions -rw-r--r--
SDL_opengl: Fix Mac build for SDK 10.9 too.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2014 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 extern "C" {
    40 #endif
    41 
    42 /**
    43  *  \file SDL_syswm.h
    44  *
    45  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
    46  *  which contains window-manager specific information and arrives whenever
    47  *  an unhandled window event occurs.  This event is ignored by default, but
    48  *  you can enable it with SDL_EventState().
    49  */
    50 #ifdef SDL_PROTOTYPES_ONLY
    51 struct SDL_SysWMinfo;
    52 #else
    53 
    54 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    55 #define WIN32_LEAN_AND_MEAN
    56 #include <windows.h>
    57 #endif
    58 
    59 #if defined(SDL_VIDEO_DRIVER_WINRT)
    60 #include <Inspectable.h>
    61 #endif
    62 
    63 /* This is the structure for custom window manager events */
    64 #if defined(SDL_VIDEO_DRIVER_X11)
    65 #if defined(__APPLE__) && defined(__MACH__)
    66 /* conflicts with Quickdraw.h */
    67 #define Cursor X11Cursor
    68 #endif
    69 
    70 #include <X11/Xlib.h>
    71 #include <X11/Xatom.h>
    72 
    73 #if defined(__APPLE__) && defined(__MACH__)
    74 /* matches the re-define above */
    75 #undef Cursor
    76 #endif
    77 
    78 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    79 
    80 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    81 #include <directfb.h>
    82 #endif
    83 
    84 #if defined(SDL_VIDEO_DRIVER_COCOA)
    85 #ifdef __OBJC__
    86 @class NSWindow;
    87 #else
    88 typedef struct _NSWindow NSWindow;
    89 #endif
    90 #endif
    91 
    92 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    93 #ifdef __OBJC__
    94 #include <UIKit/UIKit.h>
    95 #else
    96 typedef struct _UIWindow UIWindow;
    97 typedef struct _UIViewController UIViewController;
    98 #endif
    99 #endif
   100 
   101 #if defined(SDL_VIDEO_DRIVER_ANDROID)
   102 typedef struct ANativeWindow ANativeWindow;
   103 typedef void *EGLSurface;
   104 #endif
   105 
   106 /**
   107  *  These are the various supported windowing subsystems
   108  */
   109 typedef enum
   110 {
   111     SDL_SYSWM_UNKNOWN,
   112     SDL_SYSWM_WINDOWS,
   113     SDL_SYSWM_X11,
   114     SDL_SYSWM_DIRECTFB,
   115     SDL_SYSWM_COCOA,
   116     SDL_SYSWM_UIKIT,
   117     SDL_SYSWM_WAYLAND,
   118     SDL_SYSWM_MIR,
   119     SDL_SYSWM_WINRT,
   120     SDL_SYSWM_ANDROID
   121 } SDL_SYSWM_TYPE;
   122 
   123 /**
   124  *  The custom event structure.
   125  */
   126 struct SDL_SysWMmsg
   127 {
   128     SDL_version version;
   129     SDL_SYSWM_TYPE subsystem;
   130     union
   131     {
   132 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   133         struct {
   134             HWND hwnd;                  /**< The window for the message */
   135             UINT msg;                   /**< The type of message */
   136             WPARAM wParam;              /**< WORD message parameter */
   137             LPARAM lParam;              /**< LONG message parameter */
   138         } win;
   139 #endif
   140 #if defined(SDL_VIDEO_DRIVER_X11)
   141         struct {
   142             XEvent event;
   143         } x11;
   144 #endif
   145 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   146         struct {
   147             DFBEvent event;
   148         } dfb;
   149 #endif
   150 #if defined(SDL_VIDEO_DRIVER_COCOA)
   151         struct
   152         {
   153             /* No Cocoa window events yet */
   154         } cocoa;
   155 #endif
   156 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   157         struct
   158         {
   159             /* No UIKit window events yet */
   160         } uikit;
   161 #endif
   162         /* Can't have an empty union */
   163         int dummy;
   164     } msg;
   165 };
   166 
   167 /**
   168  *  The custom window manager information structure.
   169  *
   170  *  When this structure is returned, it holds information about which
   171  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   172  */
   173 struct SDL_SysWMinfo
   174 {
   175     SDL_version version;
   176     SDL_SYSWM_TYPE subsystem;
   177     union
   178     {
   179 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   180         struct
   181         {
   182             HWND window;                /**< The window handle */
   183         } win;
   184 #endif
   185 #if defined(SDL_VIDEO_DRIVER_WINRT)
   186         struct
   187         {
   188             IInspectable * window;      /**< The WinRT CoreWindow */
   189         } winrt;
   190 #endif
   191 #if defined(SDL_VIDEO_DRIVER_X11)
   192         struct
   193         {
   194             Display *display;           /**< The X11 display */
   195             Window window;              /**< The X11 window */
   196         } x11;
   197 #endif
   198 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   199         struct
   200         {
   201             IDirectFB *dfb;             /**< The directfb main interface */
   202             IDirectFBWindow *window;    /**< The directfb window handle */
   203             IDirectFBSurface *surface;  /**< The directfb client surface */
   204         } dfb;
   205 #endif
   206 #if defined(SDL_VIDEO_DRIVER_COCOA)
   207         struct
   208         {
   209             NSWindow *window;           /* The Cocoa window */
   210         } cocoa;
   211 #endif
   212 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   213         struct
   214         {
   215             UIWindow *window;           /* The UIKit window */
   216         } uikit;
   217 #endif
   218 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
   219         struct
   220         {
   221             struct wl_display *display;            /**< Wayland display */
   222             struct wl_surface *surface;            /**< Wayland surface */
   223             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
   224         } wl;
   225 #endif
   226 #if defined(SDL_VIDEO_DRIVER_MIR)
   227         struct
   228         {
   229             struct MirConnection *connection;  /**< Mir display server connection */
   230             struct MirSurface *surface;  /**< Mir surface */
   231         } mir;
   232 #endif
   233 
   234 #if defined(SDL_VIDEO_DRIVER_ANDROID)
   235         struct
   236         {
   237             ANativeWindow *window;
   238             EGLSurface surface;
   239         } android;
   240 #endif
   241 
   242         /* Can't have an empty union */
   243         int dummy;
   244     } info;
   245 };
   246 
   247 #endif /* SDL_PROTOTYPES_ONLY */
   248 
   249 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   250 
   251 /* Function prototypes */
   252 /**
   253  *  \brief This function allows access to driver-dependent window information.
   254  *
   255  *  \param window The window about which information is being requested
   256  *  \param info This structure must be initialized with the SDL version, and is
   257  *              then filled in with information about the given window.
   258  *
   259  *  \return SDL_TRUE if the function is implemented and the version member of
   260  *          the \c info struct is valid, SDL_FALSE otherwise.
   261  *
   262  *  You typically use this function like this:
   263  *  \code
   264  *  SDL_SysWMinfo info;
   265  *  SDL_VERSION(&info.version);
   266  *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
   267  *  \endcode
   268  */
   269 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   270                                                      SDL_SysWMinfo * info);
   271 
   272 
   273 /* Ends C function definitions when using C++ */
   274 #ifdef __cplusplus
   275 }
   276 #endif
   277 #include "close_code.h"
   278 
   279 #endif /* _SDL_syswm_h */
   280 
   281 /* vi: set ts=4 sw=4 expandtab: */