include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 31 Dec 2011 09:28:07 -0500
changeset 6138 4c64952a58fb
parent 5535 96594ac5fd1a
child 6885 700f1b25f77f
child 8305 3d522e6d4ae1
permissions -rw-r--r--
Happy New Year!
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2012 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 /* *INDENT-OFF* */
    40 extern "C" {
    41 /* *INDENT-ON* */
    42 #endif
    43 
    44 /**
    45  *  \file SDL_syswm.h
    46  *  
    47  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
    48  *  which contains window-manager specific information and arrives whenever
    49  *  an unhandled window event occurs.  This event is ignored by default, but
    50  *  you can enable it with SDL_EventState().
    51  */
    52 #ifdef SDL_PROTOTYPES_ONLY
    53 struct SDL_SysWMinfo;
    54 #else
    55 
    56 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    57 #define WIN32_LEAN_AND_MEAN
    58 #include <windows.h>
    59 #endif
    60 
    61 /* This is the structure for custom window manager events */
    62 #if defined(SDL_VIDEO_DRIVER_X11)
    63 #if defined(__APPLE__) && defined(__MACH__)
    64 /* conflicts with Quickdraw.h */
    65 #define Cursor X11Cursor
    66 #endif
    67 
    68 #include <X11/Xlib.h>
    69 #include <X11/Xatom.h>
    70 
    71 #if defined(__APPLE__) && defined(__MACH__)
    72 /* matches the re-define above */
    73 #undef Cursor
    74 #endif
    75 
    76 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    77 
    78 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    79 #include <directfb.h>
    80 #endif
    81 
    82 #if defined(SDL_VIDEO_DRIVER_COCOA)
    83 #ifdef __OBJC__
    84 #include <Cocoa/Cocoa.h>
    85 #else
    86 typedef struct _NSWindow NSWindow;
    87 #endif
    88 #endif
    89 
    90 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    91 #ifdef __OBJC__
    92 #include <UIKit/UIKit.h>
    93 #else
    94 typedef struct _UIWindow UIWindow;
    95 #endif
    96 #endif
    97 
    98 /** 
    99  *  These are the various supported windowing subsystems
   100  */
   101 typedef enum
   102 {
   103     SDL_SYSWM_UNKNOWN,
   104     SDL_SYSWM_WINDOWS,
   105     SDL_SYSWM_X11,
   106     SDL_SYSWM_DIRECTFB,
   107     SDL_SYSWM_COCOA,
   108     SDL_SYSWM_UIKIT,
   109 } SDL_SYSWM_TYPE;
   110 
   111 /**
   112  *  The custom event structure.
   113  */
   114 struct SDL_SysWMmsg
   115 {
   116     SDL_version version;
   117     SDL_SYSWM_TYPE subsystem;
   118     union
   119     {
   120 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   121         struct {
   122             HWND hwnd;                  /**< The window for the message */
   123             UINT msg;                   /**< The type of message */
   124             WPARAM wParam;              /**< WORD message parameter */
   125             LPARAM lParam;              /**< LONG message parameter */
   126         } win;
   127 #endif
   128 #if defined(SDL_VIDEO_DRIVER_X11)
   129         struct {
   130             XEvent event;
   131         } x11;
   132 #endif
   133 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   134         struct {
   135             DFBEvent event;
   136         } dfb;
   137 #endif
   138 #if defined(SDL_VIDEO_DRIVER_COCOA)
   139         struct
   140         {
   141             /* No Cocoa window events yet */
   142         } cocoa;
   143 #endif
   144 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   145         struct
   146         {
   147             /* No UIKit window events yet */
   148         } uikit;
   149 #endif
   150         /* Can't have an empty union */
   151         int dummy;
   152     } msg;
   153 };
   154 
   155 /**
   156  *  The custom window manager information structure.
   157  *
   158  *  When this structure is returned, it holds information about which
   159  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   160  */
   161 struct SDL_SysWMinfo
   162 {
   163     SDL_version version;
   164     SDL_SYSWM_TYPE subsystem;
   165     union
   166     {
   167 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   168         struct
   169         {
   170             HWND window;                /**< The window handle */
   171         } win;
   172 #endif
   173 #if defined(SDL_VIDEO_DRIVER_X11)
   174         struct
   175         {
   176             Display *display;           /**< The X11 display */
   177             Window window;              /**< The X11 window */
   178         } x11;
   179 #endif
   180 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   181         struct
   182         {
   183             IDirectFB *dfb;             /**< The directfb main interface */
   184             IDirectFBWindow *window;    /**< The directfb window handle */
   185             IDirectFBSurface *surface;  /**< The directfb client surface */
   186         } dfb;
   187 #endif
   188 #if defined(SDL_VIDEO_DRIVER_COCOA)
   189         struct
   190         {
   191             NSWindow *window;           /* The Cocoa window */
   192         } cocoa;
   193 #endif
   194 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   195         struct
   196         {
   197             UIWindow *window;           /* The UIKit window */
   198         } uikit;
   199 #endif
   200         /* Can't have an empty union */
   201         int dummy;
   202     } info;
   203 };
   204 
   205 #endif /* SDL_PROTOTYPES_ONLY */
   206 
   207 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   208 
   209 /* Function prototypes */
   210 /**
   211  *  \brief This function allows access to driver-dependent window information.
   212  *  
   213  *  \param window The window about which information is being requested
   214  *  \param info This structure must be initialized with the SDL version, and is 
   215  *              then filled in with information about the given window.
   216  *  
   217  *  \return SDL_TRUE if the function is implemented and the version member of 
   218  *          the \c info struct is valid, SDL_FALSE otherwise.
   219  *  
   220  *  You typically use this function like this:
   221  *  \code
   222  *  SDL_SysWMinfo info;
   223  *  SDL_VERSION(&info.version);
   224  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   225  *  \endcode
   226  */
   227 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   228                                                      SDL_SysWMinfo * info);
   229 
   230 
   231 /* Ends C function definitions when using C++ */
   232 #ifdef __cplusplus
   233 /* *INDENT-OFF* */
   234 }
   235 /* *INDENT-ON* */
   236 #endif
   237 #include "close_code.h"
   238 
   239 #endif /* _SDL_syswm_h */
   240 
   241 /* vi: set ts=4 sw=4 expandtab: */