Home | History | Annotate | Download | only in include
      1 /*
      2   Simple DirectMedia Layer
      3   Copyright (C) 1997-2014 Sam Lantinga <slouken (at) 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 /* This is the structure for custom window manager events */
     60 #if defined(SDL_VIDEO_DRIVER_X11)
     61 #if defined(__APPLE__) && defined(__MACH__)
     62 /* conflicts with Quickdraw.h */
     63 #define Cursor X11Cursor
     64 #endif
     65 
     66 #include <X11/Xlib.h>
     67 #include <X11/Xatom.h>
     68 
     69 #if defined(__APPLE__) && defined(__MACH__)
     70 /* matches the re-define above */
     71 #undef Cursor
     72 #endif
     73 
     74 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
     75 
     76 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
     77 #include <directfb.h>
     78 #endif
     79 
     80 #if defined(SDL_VIDEO_DRIVER_COCOA)
     81 #ifdef __OBJC__
     82 #include <Cocoa/Cocoa.h>
     83 #else
     84 typedef struct _NSWindow NSWindow;
     85 #endif
     86 #endif
     87 
     88 #if defined(SDL_VIDEO_DRIVER_UIKIT)
     89 #ifdef __OBJC__
     90 #include <UIKit/UIKit.h>
     91 #else
     92 typedef struct _UIWindow UIWindow;
     93 #endif
     94 #endif
     95 
     96 #if defined(SDL_VIDEO_DRIVER_MIR)
     97 #include <mir_toolkit/mir_client_library.h>
     98 #endif
     99 
    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_TYPE;
    115 
    116 /**
    117  *  The custom event structure.
    118  */
    119 struct SDL_SysWMmsg
    120 {
    121     SDL_version version;
    122     SDL_SYSWM_TYPE subsystem;
    123     union
    124     {
    125 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    126         struct {
    127             HWND hwnd;                  /**< The window for the message */
    128             UINT msg;                   /**< The type of message */
    129             WPARAM wParam;              /**< WORD message parameter */
    130             LPARAM lParam;              /**< LONG message parameter */
    131         } win;
    132 #endif
    133 #if defined(SDL_VIDEO_DRIVER_X11)
    134         struct {
    135             XEvent event;
    136         } x11;
    137 #endif
    138 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    139         struct {
    140             DFBEvent event;
    141         } dfb;
    142 #endif
    143 #if defined(SDL_VIDEO_DRIVER_COCOA)
    144         struct
    145         {
    146             /* No Cocoa window events yet */
    147         } cocoa;
    148 #endif
    149 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    150         struct
    151         {
    152             /* No UIKit window events yet */
    153         } uikit;
    154 #endif
    155         /* Can't have an empty union */
    156         int dummy;
    157     } msg;
    158 };
    159 
    160 /**
    161  *  The custom window manager information structure.
    162  *
    163  *  When this structure is returned, it holds information about which
    164  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
    165  */
    166 struct SDL_SysWMinfo
    167 {
    168     SDL_version version;
    169     SDL_SYSWM_TYPE subsystem;
    170     union
    171     {
    172 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    173         struct
    174         {
    175             HWND window;                /**< The window handle */
    176         } win;
    177 #endif
    178 #if defined(SDL_VIDEO_DRIVER_X11)
    179         struct
    180         {
    181             Display *display;           /**< The X11 display */
    182             Window window;              /**< The X11 window */
    183         } x11;
    184 #endif
    185 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    186         struct
    187         {
    188             IDirectFB *dfb;             /**< The directfb main interface */
    189             IDirectFBWindow *window;    /**< The directfb window handle */
    190             IDirectFBSurface *surface;  /**< The directfb client surface */
    191         } dfb;
    192 #endif
    193 #if defined(SDL_VIDEO_DRIVER_COCOA)
    194         struct
    195         {
    196             NSWindow *window;           /* The Cocoa window */
    197         } cocoa;
    198 #endif
    199 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    200         struct
    201         {
    202             UIWindow *window;           /* The UIKit window */
    203         } uikit;
    204 #endif
    205 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
    206         struct
    207         {
    208             struct wl_display *display;            /**< Wayland display */
    209             struct wl_surface *surface;            /**< Wayland surface */
    210             struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
    211         } wl;
    212 #endif
    213 #if defined(SDL_VIDEO_DRIVER_MIR)
    214         struct
    215         {
    216             MirConnection *connection;  /**< Mir display server connection */
    217             MirSurface *surface;  /**< Mir surface */
    218         } mir;
    219 #endif
    220 
    221         /* Can't have an empty union */
    222         int dummy;
    223     } info;
    224 };
    225 
    226 #endif /* SDL_PROTOTYPES_ONLY */
    227 
    228 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
    229 
    230 /* Function prototypes */
    231 /**
    232  *  \brief This function allows access to driver-dependent window information.
    233  *
    234  *  \param window The window about which information is being requested
    235  *  \param info This structure must be initialized with the SDL version, and is
    236  *              then filled in with information about the given window.
    237  *
    238  *  \return SDL_TRUE if the function is implemented and the version member of
    239  *          the \c info struct is valid, SDL_FALSE otherwise.
    240  *
    241  *  You typically use this function like this:
    242  *  \code
    243  *  SDL_SysWMinfo info;
    244  *  SDL_VERSION(&info.version);
    245  *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
    246  *  \endcode
    247  */
    248 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
    249                                                      SDL_SysWMinfo * info);
    250 
    251 
    252 /* Ends C function definitions when using C++ */
    253 #ifdef __cplusplus
    254 }
    255 #endif
    256 #include "close_code.h"
    257 
    258 #endif /* _SDL_syswm_h */
    259 
    260 /* vi: set ts=4 sw=4 expandtab: */
    261