include/SDL_syswm.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 29 Apr 2014 12:00:28 -0400
changeset 8744 8c0fafc6b438
parent 8731 ede9d13dad21
child 8799 e2fd743d84ea
permissions -rw-r--r--
Removed comma at end of enum in a public header, to make -Wpedantic happy.
     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 #include <Cocoa/Cocoa.h>
    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 /**
   102  *  These are the various supported windowing subsystems
   103  */
   104 typedef enum
   105 {
   106     SDL_SYSWM_UNKNOWN,
   107     SDL_SYSWM_WINDOWS,
   108     SDL_SYSWM_X11,
   109     SDL_SYSWM_DIRECTFB,
   110     SDL_SYSWM_COCOA,
   111     SDL_SYSWM_UIKIT,
   112     SDL_SYSWM_WAYLAND,
   113     SDL_SYSWM_MIR,
   114     SDL_SYSWM_WINRT
   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             IInspectable * window;      /**< The WinRT 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         } uikit;
   211 #endif
   212 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
   213         struct
   214         {
   215             struct wl_display *display;            /**< Wayland display */
   216             struct wl_surface *surface;            /**< Wayland surface */
   217             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
   218         } wl;
   219 #endif
   220 #if defined(SDL_VIDEO_DRIVER_MIR)
   221         struct
   222         {
   223             struct MirConnection *connection;  /**< Mir display server connection */
   224             struct MirSurface *surface;  /**< Mir surface */
   225         } mir;
   226 #endif
   227 
   228         /* Can't have an empty union */
   229         int dummy;
   230     } info;
   231 };
   232 
   233 #endif /* SDL_PROTOTYPES_ONLY */
   234 
   235 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   236 
   237 /* Function prototypes */
   238 /**
   239  *  \brief This function allows access to driver-dependent window information.
   240  *
   241  *  \param window The window about which information is being requested
   242  *  \param info This structure must be initialized with the SDL version, and is
   243  *              then filled in with information about the given window.
   244  *
   245  *  \return SDL_TRUE if the function is implemented and the version member of
   246  *          the \c info struct is valid, SDL_FALSE otherwise.
   247  *
   248  *  You typically use this function like this:
   249  *  \code
   250  *  SDL_SysWMinfo info;
   251  *  SDL_VERSION(&info.version);
   252  *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
   253  *  \endcode
   254  */
   255 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   256                                                      SDL_SysWMinfo * info);
   257 
   258 
   259 /* Ends C function definitions when using C++ */
   260 #ifdef __cplusplus
   261 }
   262 #endif
   263 #include "close_code.h"
   264 
   265 #endif /* _SDL_syswm_h */
   266 
   267 /* vi: set ts=4 sw=4 expandtab: */