include/SDL_syswm.h
author David Ludwig <dludwig@pobox.com>
Sat, 09 Feb 2013 14:35:06 -0500
changeset 8411 aca0591bc58f
parent 8305 3d522e6d4ae1
child 8439 14d94a8a9fb6
permissions -rw-r--r--
WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_syswm.h
slouken@3407
    24
 *  
slouken@3407
    25
 *  Include file for SDL custom system window manager hooks.
slouken@1895
    26
 */
slouken@0
    27
slouken@0
    28
#ifndef _SDL_syswm_h
slouken@0
    29
#define _SDL_syswm_h
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1358
    32
#include "SDL_error.h"
slouken@1895
    33
#include "SDL_video.h"
slouken@0
    34
#include "SDL_version.h"
slouken@0
    35
slouken@0
    36
#include "begin_code.h"
slouken@0
    37
/* Set up for C function definitions, even when using C++ */
slouken@0
    38
#ifdef __cplusplus
slouken@1895
    39
/* *INDENT-OFF* */
slouken@0
    40
extern "C" {
slouken@1895
    41
/* *INDENT-ON* */
slouken@0
    42
#endif
slouken@0
    43
slouken@3407
    44
/**
slouken@3407
    45
 *  \file SDL_syswm.h
slouken@3407
    46
 *  
slouken@3407
    47
 *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
slouken@3407
    48
 *  which contains window-manager specific information and arrives whenever
slouken@3407
    49
 *  an unhandled window event occurs.  This event is ignored by default, but
slouken@3407
    50
 *  you can enable it with SDL_EventState().
slouken@3407
    51
 */
slouken@0
    52
#ifdef SDL_PROTOTYPES_ONLY
slouken@0
    53
struct SDL_SysWMinfo;
slouken@0
    54
#else
slouken@0
    55
slouken@5062
    56
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
    57
#define WIN32_LEAN_AND_MEAN
slouken@4900
    58
#include <windows.h>
slouken@4900
    59
#endif
slouken@4900
    60
slouken@1361
    61
/* This is the structure for custom window manager events */
slouken@1626
    62
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    63
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    64
/* conflicts with Quickdraw.h */
icculus@1133
    65
#define Cursor X11Cursor
icculus@1133
    66
#endif
icculus@1133
    67
slouken@0
    68
#include <X11/Xlib.h>
slouken@0
    69
#include <X11/Xatom.h>
slouken@0
    70
icculus@1133
    71
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    72
/* matches the re-define above */
icculus@1133
    73
#undef Cursor
icculus@1133
    74
#endif
icculus@1133
    75
slouken@4899
    76
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
slouken@4899
    77
slouken@4899
    78
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@5199
    79
#include <directfb.h>
slouken@4899
    80
#endif
slouken@4900
    81
slouken@4900
    82
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
    83
#ifdef __OBJC__
slouken@4900
    84
#include <Cocoa/Cocoa.h>
slouken@4900
    85
#else
slouken@4900
    86
typedef struct _NSWindow NSWindow;
slouken@4900
    87
#endif
slouken@4900
    88
#endif
slouken@4900
    89
slouken@5056
    90
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
    91
#ifdef __OBJC__
slouken@5056
    92
#include <UIKit/UIKit.h>
slouken@5056
    93
#else
slouken@5056
    94
typedef struct _UIWindow UIWindow;
dludwig@8305
    95
typedef struct _UIViewController UIViewController;
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,
dludwig@8411
   106
    SDL_SYSWM_WINDOWSRT,
slouken@4899
   107
    SDL_SYSWM_X11,
slouken@4899
   108
    SDL_SYSWM_DIRECTFB,
slouken@4900
   109
    SDL_SYSWM_COCOA,
slouken@5056
   110
    SDL_SYSWM_UIKIT,
slouken@0
   111
} SDL_SYSWM_TYPE;
slouken@0
   112
slouken@3407
   113
/**
slouken@4900
   114
 *  The custom event structure.
slouken@3407
   115
 */
slouken@1895
   116
struct SDL_SysWMmsg
slouken@1895
   117
{
slouken@1895
   118
    SDL_version version;
slouken@1895
   119
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   120
    union
slouken@1895
   121
    {
slouken@5062
   122
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   123
        struct {
slouken@4900
   124
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   125
            UINT msg;                   /**< The type of message */
slouken@4900
   126
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   127
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   128
        } win;
slouken@5065
   129
#endif
slouken@5065
   130
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   131
        struct {
slouken@4900
   132
            XEvent event;
slouken@4900
   133
        } x11;
slouken@5065
   134
#endif
slouken@5065
   135
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   136
        struct {
slouken@4900
   137
            DFBEvent event;
slouken@4900
   138
        } dfb;
slouken@5065
   139
#endif
slouken@5065
   140
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   141
        struct
slouken@4900
   142
        {
slouken@4900
   143
            /* No Cocoa window events yet */
slouken@4900
   144
        } cocoa;
slouken@5065
   145
#endif
slouken@5065
   146
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   147
        struct
slouken@5056
   148
        {
slouken@5056
   149
            /* No UIKit window events yet */
slouken@5056
   150
        } uikit;
slouken@5065
   151
#endif
slouken@5063
   152
        /* Can't have an empty union */
slouken@5063
   153
        int dummy;
slouken@5056
   154
    } msg;
slouken@0
   155
};
slouken@0
   156
slouken@3407
   157
/**
slouken@4900
   158
 *  The custom window manager information structure.
slouken@3407
   159
 *
slouken@3407
   160
 *  When this structure is returned, it holds information about which
slouken@3407
   161
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   162
 */
slouken@1895
   163
struct SDL_SysWMinfo
slouken@1895
   164
{
slouken@1895
   165
    SDL_version version;
slouken@1895
   166
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   167
    union
slouken@1895
   168
    {
slouken@5062
   169
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   170
        struct
slouken@4900
   171
        {
slouken@4903
   172
            HWND window;                /**< The window handle */
slouken@4900
   173
        } win;
slouken@5065
   174
#endif
dludwig@8411
   175
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   176
        struct
dludwig@8411
   177
        {
dludwig@8411
   178
            void * window;          /**< The Windows RT CoreWindow, casted from 'CoreWindow ^*' to 'void *' */
dludwig@8411
   179
        } winrt;
dludwig@8411
   180
#endif
slouken@5065
   181
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   182
        struct
slouken@1895
   183
        {
slouken@4900
   184
            Display *display;           /**< The X11 display */
slouken@4903
   185
            Window window;              /**< The X11 window */
slouken@1895
   186
        } x11;
slouken@5065
   187
#endif
slouken@5065
   188
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   189
        struct
slouken@4899
   190
        {
slouken@4903
   191
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   192
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   193
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   194
        } dfb;
slouken@5065
   195
#endif
slouken@5065
   196
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   197
        struct
slouken@4900
   198
        {
slouken@4903
   199
            NSWindow *window;           /* The Cocoa window */
slouken@4900
   200
        } cocoa;
slouken@5065
   201
#endif
slouken@5065
   202
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   203
        struct
slouken@5056
   204
        {
slouken@5056
   205
            UIWindow *window;           /* The UIKit window */
dludwig@8305
   206
            UIViewController *viewcontroller;   /* The UIKit view controller */
slouken@5056
   207
        } uikit;
slouken@5065
   208
#endif
slouken@5063
   209
        /* Can't have an empty union */
slouken@5063
   210
        int dummy;
slouken@5056
   211
    } info;
slouken@1895
   212
};
slouken@0
   213
slouken@0
   214
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   215
slouken@1895
   216
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   217
slouken@0
   218
/* Function prototypes */
slouken@1895
   219
/**
slouken@3407
   220
 *  \brief This function allows access to driver-dependent window information.
slouken@3407
   221
 *  
slouken@4530
   222
 *  \param window The window about which information is being requested
slouken@3407
   223
 *  \param info This structure must be initialized with the SDL version, and is 
slouken@3407
   224
 *              then filled in with information about the given window.
slouken@3407
   225
 *  
slouken@3407
   226
 *  \return SDL_TRUE if the function is implemented and the version member of 
slouken@3407
   227
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@3407
   228
 *  
slouken@3407
   229
 *  You typically use this function like this:
slouken@3407
   230
 *  \code
slouken@4895
   231
 *  SDL_SysWMinfo info;
slouken@3407
   232
 *  SDL_VERSION(&info.version);
slouken@3407
   233
 *  if ( SDL_GetWindowWMInfo(&info) ) { ... }
slouken@3407
   234
 *  \endcode
slouken@0
   235
 */
slouken@3685
   236
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   237
                                                     SDL_SysWMinfo * info);
slouken@0
   238
slouken@0
   239
slouken@0
   240
/* Ends C function definitions when using C++ */
slouken@0
   241
#ifdef __cplusplus
slouken@1895
   242
/* *INDENT-OFF* */
slouken@0
   243
}
slouken@1895
   244
/* *INDENT-ON* */
slouken@0
   245
#endif
slouken@0
   246
#include "close_code.h"
slouken@0
   247
slouken@0
   248
#endif /* _SDL_syswm_h */
slouken@1895
   249
slouken@1895
   250
/* vi: set ts=4 sw=4 expandtab: */