include/SDL_syswm.h
author Jørgen P. Tjernø <jorgen@uberent.com>
Mon, 30 Jun 2014 17:22:08 -0700
changeset 8968 47decd0106f8
parent 8812 b0f96c169c97
child 9035 d6464107048c
permissions -rw-r--r--
Apply WIN32_LEAN_AND_MEAN redefine fix to SDL_syswm.h too.

This is related to 7a261af2d612, which fixes bug 2508.
     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 #endif
   102 
   103 #if defined(SDL_VIDEO_DRIVER_ANDROID)
   104 typedef struct ANativeWindow ANativeWindow;
   105 typedef void *EGLSurface;
   106 #endif
   107 
   108 /**
   109  *  These are the various supported windowing subsystems
   110  */
   111 typedef enum
   112 {
   113     SDL_SYSWM_UNKNOWN,
   114     SDL_SYSWM_WINDOWS,
   115     SDL_SYSWM_X11,
   116     SDL_SYSWM_DIRECTFB,
   117     SDL_SYSWM_COCOA,
   118     SDL_SYSWM_UIKIT,
   119     SDL_SYSWM_WAYLAND,
   120     SDL_SYSWM_MIR,
   121     SDL_SYSWM_WINRT,
   122     SDL_SYSWM_ANDROID
   123 } SDL_SYSWM_TYPE;
   124 
   125 /**
   126  *  The custom event structure.
   127  */
   128 struct SDL_SysWMmsg
   129 {
   130     SDL_version version;
   131     SDL_SYSWM_TYPE subsystem;
   132     union
   133     {
   134 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   135         struct {
   136             HWND hwnd;                  /**< The window for the message */
   137             UINT msg;                   /**< The type of message */
   138             WPARAM wParam;              /**< WORD message parameter */
   139             LPARAM lParam;              /**< LONG message parameter */
   140         } win;
   141 #endif
   142 #if defined(SDL_VIDEO_DRIVER_X11)
   143         struct {
   144             XEvent event;
   145         } x11;
   146 #endif
   147 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   148         struct {
   149             DFBEvent event;
   150         } dfb;
   151 #endif
   152 #if defined(SDL_VIDEO_DRIVER_COCOA)
   153         struct
   154         {
   155             /* No Cocoa window events yet */
   156         } cocoa;
   157 #endif
   158 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   159         struct
   160         {
   161             /* No UIKit window events yet */
   162         } uikit;
   163 #endif
   164         /* Can't have an empty union */
   165         int dummy;
   166     } msg;
   167 };
   168 
   169 /**
   170  *  The custom window manager information structure.
   171  *
   172  *  When this structure is returned, it holds information about which
   173  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   174  */
   175 struct SDL_SysWMinfo
   176 {
   177     SDL_version version;
   178     SDL_SYSWM_TYPE subsystem;
   179     union
   180     {
   181 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   182         struct
   183         {
   184             HWND window;                /**< The window handle */
   185         } win;
   186 #endif
   187 #if defined(SDL_VIDEO_DRIVER_WINRT)
   188         struct
   189         {
   190             IInspectable * window;      /**< The WinRT CoreWindow */
   191         } winrt;
   192 #endif
   193 #if defined(SDL_VIDEO_DRIVER_X11)
   194         struct
   195         {
   196             Display *display;           /**< The X11 display */
   197             Window window;              /**< The X11 window */
   198         } x11;
   199 #endif
   200 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   201         struct
   202         {
   203             IDirectFB *dfb;             /**< The directfb main interface */
   204             IDirectFBWindow *window;    /**< The directfb window handle */
   205             IDirectFBSurface *surface;  /**< The directfb client surface */
   206         } dfb;
   207 #endif
   208 #if defined(SDL_VIDEO_DRIVER_COCOA)
   209         struct
   210         {
   211             NSWindow *window;           /* The Cocoa window */
   212         } cocoa;
   213 #endif
   214 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   215         struct
   216         {
   217             UIWindow *window;           /* The UIKit window */
   218         } uikit;
   219 #endif
   220 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
   221         struct
   222         {
   223             struct wl_display *display;            /**< Wayland display */
   224             struct wl_surface *surface;            /**< Wayland surface */
   225             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
   226         } wl;
   227 #endif
   228 #if defined(SDL_VIDEO_DRIVER_MIR)
   229         struct
   230         {
   231             struct MirConnection *connection;  /**< Mir display server connection */
   232             struct MirSurface *surface;  /**< Mir surface */
   233         } mir;
   234 #endif
   235 
   236 #if defined(SDL_VIDEO_DRIVER_ANDROID)
   237         struct
   238         {
   239             ANativeWindow *window;
   240             EGLSurface surface;
   241         } android;
   242 #endif
   243 
   244         /* Can't have an empty union */
   245         int dummy;
   246     } info;
   247 };
   248 
   249 #endif /* SDL_PROTOTYPES_ONLY */
   250 
   251 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   252 
   253 /* Function prototypes */
   254 /**
   255  *  \brief This function allows access to driver-dependent window information.
   256  *
   257  *  \param window The window about which information is being requested
   258  *  \param info This structure must be initialized with the SDL version, and is
   259  *              then filled in with information about the given window.
   260  *
   261  *  \return SDL_TRUE if the function is implemented and the version member of
   262  *          the \c info struct is valid, SDL_FALSE otherwise.
   263  *
   264  *  You typically use this function like this:
   265  *  \code
   266  *  SDL_SysWMinfo info;
   267  *  SDL_VERSION(&info.version);
   268  *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
   269  *  \endcode
   270  */
   271 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   272                                                      SDL_SysWMinfo * info);
   273 
   274 
   275 /* Ends C function definitions when using C++ */
   276 #ifdef __cplusplus
   277 }
   278 #endif
   279 #include "close_code.h"
   280 
   281 #endif /* _SDL_syswm_h */
   282 
   283 /* vi: set ts=4 sw=4 expandtab: */