include/SDL_syswm.h
author Alex Szpakowski <slime73@gmail.com>
Thu, 09 Apr 2015 19:28:00 -0300
branchiOS-improvements
changeset 9540 32ddc92d78cf
parent 9536 3c87b8f9dc58
child 9586 037074526d4c
permissions -rw-r--r--
Added framebuffer and colorbuffer members to the uikit portion of the SDL_SysWMinfo struct, removed SDL_iOSGetViewRenderbuffer and SDL_iOSGetViewFramebuffer.
     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 #ifndef WIN32_LEAN_AND_MEAN
    56 #define WIN32_LEAN_AND_MEAN
    57 #endif
    58 #include <windows.h>
    59 #endif
    60 
    61 #if defined(SDL_VIDEO_DRIVER_WINRT)
    62 #include <Inspectable.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 @class NSWindow;
    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 typedef Uint32 GLuint;
   102 #endif
   103 
   104 #if defined(SDL_VIDEO_DRIVER_ANDROID)
   105 typedef struct ANativeWindow ANativeWindow;
   106 typedef void *EGLSurface;
   107 #endif
   108 
   109 /**
   110  *  These are the various supported windowing subsystems
   111  */
   112 typedef enum
   113 {
   114     SDL_SYSWM_UNKNOWN,
   115     SDL_SYSWM_WINDOWS,
   116     SDL_SYSWM_X11,
   117     SDL_SYSWM_DIRECTFB,
   118     SDL_SYSWM_COCOA,
   119     SDL_SYSWM_UIKIT,
   120     SDL_SYSWM_WAYLAND,
   121     SDL_SYSWM_MIR,
   122     SDL_SYSWM_WINRT,
   123     SDL_SYSWM_ANDROID
   124 } SDL_SYSWM_TYPE;
   125 
   126 /**
   127  *  The custom event structure.
   128  */
   129 struct SDL_SysWMmsg
   130 {
   131     SDL_version version;
   132     SDL_SYSWM_TYPE subsystem;
   133     union
   134     {
   135 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   136         struct {
   137             HWND hwnd;                  /**< The window for the message */
   138             UINT msg;                   /**< The type of message */
   139             WPARAM wParam;              /**< WORD message parameter */
   140             LPARAM lParam;              /**< LONG message parameter */
   141         } win;
   142 #endif
   143 #if defined(SDL_VIDEO_DRIVER_X11)
   144         struct {
   145             XEvent event;
   146         } x11;
   147 #endif
   148 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   149         struct {
   150             DFBEvent event;
   151         } dfb;
   152 #endif
   153 #if defined(SDL_VIDEO_DRIVER_COCOA)
   154         struct
   155         {
   156             /* Latest version of Xcode clang complains about empty structs in C v. C++:
   157                  error: empty struct has size 0 in C, size 1 in C++
   158              */
   159             int dummy;
   160             /* No Cocoa window events yet */
   161         } cocoa;
   162 #endif
   163 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   164         struct
   165         {
   166             /* No UIKit window events yet */
   167         } uikit;
   168 #endif
   169         /* Can't have an empty union */
   170         int dummy;
   171     } msg;
   172 };
   173 
   174 /**
   175  *  The custom window manager information structure.
   176  *
   177  *  When this structure is returned, it holds information about which
   178  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   179  */
   180 struct SDL_SysWMinfo
   181 {
   182     SDL_version version;
   183     SDL_SYSWM_TYPE subsystem;
   184     union
   185     {
   186 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   187         struct
   188         {
   189             HWND window;                /**< The window handle */
   190             HDC hdc;                    /**< The window device context */
   191         } win;
   192 #endif
   193 #if defined(SDL_VIDEO_DRIVER_WINRT)
   194         struct
   195         {
   196             IInspectable * window;      /**< The WinRT CoreWindow */
   197         } winrt;
   198 #endif
   199 #if defined(SDL_VIDEO_DRIVER_X11)
   200         struct
   201         {
   202             Display *display;           /**< The X11 display */
   203             Window window;              /**< The X11 window */
   204         } x11;
   205 #endif
   206 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   207         struct
   208         {
   209             IDirectFB *dfb;             /**< The directfb main interface */
   210             IDirectFBWindow *window;    /**< The directfb window handle */
   211             IDirectFBSurface *surface;  /**< The directfb client surface */
   212         } dfb;
   213 #endif
   214 #if defined(SDL_VIDEO_DRIVER_COCOA)
   215         struct
   216         {
   217 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
   218             NSWindow __unsafe_unretained *window; /* The Cocoa window */
   219 #else
   220             NSWindow *window;                     /* The Cocoa window */
   221 #endif
   222         } cocoa;
   223 #endif
   224 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   225         struct
   226         {
   227 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
   228             UIWindow __unsafe_unretained *window; /* The UIKit window */
   229 #else
   230             UIWindow *window;                     /* The UIKit window */
   231 #endif
   232             GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
   233             GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
   234         } uikit;
   235 #endif
   236 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
   237         struct
   238         {
   239             struct wl_display *display;            /**< Wayland display */
   240             struct wl_surface *surface;            /**< Wayland surface */
   241             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
   242         } wl;
   243 #endif
   244 #if defined(SDL_VIDEO_DRIVER_MIR)
   245         struct
   246         {
   247             struct MirConnection *connection;  /**< Mir display server connection */
   248             struct MirSurface *surface;  /**< Mir surface */
   249         } mir;
   250 #endif
   251 
   252 #if defined(SDL_VIDEO_DRIVER_ANDROID)
   253         struct
   254         {
   255             ANativeWindow *window;
   256             EGLSurface surface;
   257         } android;
   258 #endif
   259 
   260         /* Can't have an empty union */
   261         int dummy;
   262     } info;
   263 };
   264 
   265 #endif /* SDL_PROTOTYPES_ONLY */
   266 
   267 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   268 
   269 /* Function prototypes */
   270 /**
   271  *  \brief This function allows access to driver-dependent window information.
   272  *
   273  *  \param window The window about which information is being requested
   274  *  \param info This structure must be initialized with the SDL version, and is
   275  *              then filled in with information about the given window.
   276  *
   277  *  \return SDL_TRUE if the function is implemented and the version member of
   278  *          the \c info struct is valid, SDL_FALSE otherwise.
   279  *
   280  *  You typically use this function like this:
   281  *  \code
   282  *  SDL_SysWMinfo info;
   283  *  SDL_VERSION(&info.version);
   284  *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
   285  *  \endcode
   286  */
   287 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   288                                                      SDL_SysWMinfo * info);
   289 
   290 
   291 /* Ends C function definitions when using C++ */
   292 #ifdef __cplusplus
   293 }
   294 #endif
   295 #include "close_code.h"
   296 
   297 #endif /* _SDL_syswm_h */
   298 
   299 /* vi: set ts=4 sw=4 expandtab: */