include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 05 Feb 2011 16:07:10 -0800
changeset 5199 164f20ba08eb
parent 5065 7e4c7790700e
child 5262 b530ef003506
permissions -rw-r--r--
Updated the DirectFB support, from Couriersud

attached is a working directfb driver diff which works with the current
changes. There are a number of changes around it as well, e.g.
configure.in.

The directfb renderdriver right now still depends on a some "includes"
from src/video/directfb. That's why it is not yet moved to the new
render folder.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 /**
    24  *  \file SDL_syswm.h
    25  *  
    26  *  Include file for SDL custom system window manager hooks.
    27  */
    28 
    29 #ifndef _SDL_syswm_h
    30 #define _SDL_syswm_h
    31 
    32 #include "SDL_stdinc.h"
    33 #include "SDL_error.h"
    34 #include "SDL_video.h"
    35 #include "SDL_version.h"
    36 
    37 #include "begin_code.h"
    38 /* Set up for C function definitions, even when using C++ */
    39 #ifdef __cplusplus
    40 /* *INDENT-OFF* */
    41 extern "C" {
    42 /* *INDENT-ON* */
    43 #endif
    44 
    45 /**
    46  *  \file SDL_syswm.h
    47  *  
    48  *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
    49  *  which contains window-manager specific information and arrives whenever
    50  *  an unhandled window event occurs.  This event is ignored by default, but
    51  *  you can enable it with SDL_EventState().
    52  */
    53 #ifdef SDL_PROTOTYPES_ONLY
    54 struct SDL_SysWMinfo;
    55 #else
    56 
    57 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
    58 #define WIN32_LEAN_AND_MEAN
    59 #include <windows.h>
    60 #endif
    61 
    62 /* This is the structure for custom window manager events */
    63 #if defined(SDL_VIDEO_DRIVER_X11)
    64 #if defined(__APPLE__) && defined(__MACH__)
    65 /* conflicts with Quickdraw.h */
    66 #define Cursor X11Cursor
    67 #endif
    68 
    69 #include <X11/Xlib.h>
    70 #include <X11/Xatom.h>
    71 
    72 #if defined(__APPLE__) && defined(__MACH__)
    73 /* matches the re-define above */
    74 #undef Cursor
    75 #endif
    76 
    77 #endif /* defined(SDL_VIDEO_DRIVER_X11) */
    78 
    79 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
    80 #include <directfb.h>
    81 #endif
    82 
    83 #if defined(SDL_VIDEO_DRIVER_COCOA)
    84 #ifdef __OBJC__
    85 #include <Cocoa/Cocoa.h>
    86 #else
    87 typedef struct _NSWindow NSWindow;
    88 #endif
    89 #endif
    90 
    91 #if defined(SDL_VIDEO_DRIVER_UIKIT)
    92 #ifdef __OBJC__
    93 #include <UIKit/UIKit.h>
    94 #else
    95 typedef struct _UIWindow UIWindow;
    96 #endif
    97 #endif
    98 
    99 /** 
   100  *  These are the various supported windowing subsystems
   101  */
   102 typedef enum
   103 {
   104     SDL_SYSWM_UNKNOWN,
   105     SDL_SYSWM_WINDOWS,
   106     SDL_SYSWM_X11,
   107     SDL_SYSWM_DIRECTFB,
   108     SDL_SYSWM_COCOA,
   109     SDL_SYSWM_UIKIT,
   110 } SDL_SYSWM_TYPE;
   111 
   112 /**
   113  *  The custom event structure.
   114  */
   115 struct SDL_SysWMmsg
   116 {
   117     SDL_version version;
   118     SDL_SYSWM_TYPE subsystem;
   119     union
   120     {
   121 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   122         struct {
   123             HWND hwnd;                  /**< The window for the message */
   124             UINT msg;                   /**< The type of message */
   125             WPARAM wParam;              /**< WORD message parameter */
   126             LPARAM lParam;              /**< LONG message parameter */
   127         } win;
   128 #endif
   129 #if defined(SDL_VIDEO_DRIVER_X11)
   130         struct {
   131             XEvent event;
   132         } x11;
   133 #endif
   134 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   135         struct {
   136             DFBEvent event;
   137         } dfb;
   138 #endif
   139 #if defined(SDL_VIDEO_DRIVER_COCOA)
   140         struct
   141         {
   142             /* No Cocoa window events yet */
   143         } cocoa;
   144 #endif
   145 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   146         struct
   147         {
   148             /* No UIKit window events yet */
   149         } uikit;
   150 #endif
   151         /* Can't have an empty union */
   152         int dummy;
   153     } msg;
   154 };
   155 
   156 /**
   157  *  The custom window manager information structure.
   158  *
   159  *  When this structure is returned, it holds information about which
   160  *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
   161  */
   162 struct SDL_SysWMinfo
   163 {
   164     SDL_version version;
   165     SDL_SYSWM_TYPE subsystem;
   166     union
   167     {
   168 #if defined(SDL_VIDEO_DRIVER_WINDOWS)
   169         struct
   170         {
   171             HWND window;                /**< The window handle */
   172         } win;
   173 #endif
   174 #if defined(SDL_VIDEO_DRIVER_X11)
   175         struct
   176         {
   177             Display *display;           /**< The X11 display */
   178             Window window;              /**< The X11 window */
   179         } x11;
   180 #endif
   181 #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
   182         struct
   183         {
   184             IDirectFB *dfb;             /**< The directfb main interface */
   185             IDirectFBWindow *window;    /**< The directfb window handle */
   186             IDirectFBSurface *surface;  /**< The directfb client surface */
   187         } dfb;
   188 #endif
   189 #if defined(SDL_VIDEO_DRIVER_COCOA)
   190         struct
   191         {
   192             NSWindow *window;           /* The Cocoa window */
   193         } cocoa;
   194 #endif
   195 #if defined(SDL_VIDEO_DRIVER_UIKIT)
   196         struct
   197         {
   198             UIWindow *window;           /* The UIKit window */
   199         } uikit;
   200 #endif
   201         /* Can't have an empty union */
   202         int dummy;
   203     } info;
   204 };
   205 
   206 #endif /* SDL_PROTOTYPES_ONLY */
   207 
   208 typedef struct SDL_SysWMinfo SDL_SysWMinfo;
   209 
   210 /* Function prototypes */
   211 /**
   212  *  \brief This function allows access to driver-dependent window information.
   213  *  
   214  *  \param window The window about which information is being requested
   215  *  \param info This structure must be initialized with the SDL version, and is 
   216  *              then filled in with information about the given window.
   217  *  
   218  *  \return SDL_TRUE if the function is implemented and the version member of 
   219  *          the \c info struct is valid, SDL_FALSE otherwise.
   220  *  
   221  *  You typically use this function like this:
   222  *  \code
   223  *  SDL_SysWMinfo info;
   224  *  SDL_VERSION(&info.version);
   225  *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
   226  *  \endcode
   227  */
   228 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
   229                                                      SDL_SysWMinfo * info);
   230 
   231 
   232 /* Ends C function definitions when using C++ */
   233 #ifdef __cplusplus
   234 /* *INDENT-OFF* */
   235 }
   236 /* *INDENT-ON* */
   237 #endif
   238 #include "close_code.h"
   239 
   240 #endif /* _SDL_syswm_h */
   241 
   242 /* vi: set ts=4 sw=4 expandtab: */