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