include/SDL_syswm.h
author David Ludwig <dludwig@pobox.com>
Tue, 27 Aug 2013 11:44:43 -0400
changeset 8496 9f0a4fbc6452
parent 8477 ad08f0d710f3
child 8500 f25ef28d61e8
permissions -rw-r--r--
WinRT: renamed SDL_SYSWM_WINDOWSRT to SDL_SYSWM_WINRT
This is part of an overall effort to use the name, "WinRT", rather than "WindowsRT" (or "Windows RT"), as the shorthand name often seems to mean something different than the longhand name. (WinRT is an API, Windows RT is a product name)
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 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@7191
    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@0
    39
extern "C" {
slouken@0
    40
#endif
slouken@0
    41
slouken@3407
    42
/**
slouken@3407
    43
 *  \file SDL_syswm.h
slouken@7191
    44
 *
slouken@3407
    45
 *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
slouken@3407
    46
 *  which contains window-manager specific information and arrives whenever
slouken@3407
    47
 *  an unhandled window event occurs.  This event is ignored by default, but
slouken@3407
    48
 *  you can enable it with SDL_EventState().
slouken@3407
    49
 */
slouken@0
    50
#ifdef SDL_PROTOTYPES_ONLY
slouken@0
    51
struct SDL_SysWMinfo;
slouken@0
    52
#else
slouken@0
    53
slouken@5062
    54
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
    55
#define WIN32_LEAN_AND_MEAN
slouken@4900
    56
#include <windows.h>
slouken@4900
    57
#endif
slouken@4900
    58
dludwig@8463
    59
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8463
    60
#include <Unknwn.h>
dludwig@8463
    61
#endif
dludwig@8463
    62
slouken@1361
    63
/* This is the structure for custom window manager events */
slouken@1626
    64
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    65
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    66
/* conflicts with Quickdraw.h */
icculus@1133
    67
#define Cursor X11Cursor
icculus@1133
    68
#endif
icculus@1133
    69
slouken@0
    70
#include <X11/Xlib.h>
slouken@0
    71
#include <X11/Xatom.h>
slouken@0
    72
icculus@1133
    73
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    74
/* matches the re-define above */
icculus@1133
    75
#undef Cursor
icculus@1133
    76
#endif
icculus@1133
    77
slouken@4899
    78
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
slouken@4899
    79
slouken@4899
    80
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@5199
    81
#include <directfb.h>
slouken@4899
    82
#endif
slouken@4900
    83
slouken@4900
    84
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
    85
#ifdef __OBJC__
slouken@4900
    86
#include <Cocoa/Cocoa.h>
slouken@4900
    87
#else
slouken@4900
    88
typedef struct _NSWindow NSWindow;
slouken@4900
    89
#endif
slouken@4900
    90
#endif
slouken@4900
    91
slouken@5056
    92
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
    93
#ifdef __OBJC__
slouken@5056
    94
#include <UIKit/UIKit.h>
slouken@5056
    95
#else
slouken@5056
    96
typedef struct _UIWindow UIWindow;
dludwig@8305
    97
typedef struct _UIViewController UIViewController;
slouken@5056
    98
#endif
slouken@5056
    99
#endif
slouken@5056
   100
slouken@7191
   101
/**
slouken@4900
   102
 *  These are the various supported windowing subsystems
slouken@3407
   103
 */
slouken@1895
   104
typedef enum
slouken@1895
   105
{
slouken@4900
   106
    SDL_SYSWM_UNKNOWN,
slouken@4900
   107
    SDL_SYSWM_WINDOWS,
dludwig@8496
   108
    SDL_SYSWM_WINRT,
slouken@4899
   109
    SDL_SYSWM_X11,
slouken@4899
   110
    SDL_SYSWM_DIRECTFB,
slouken@4900
   111
    SDL_SYSWM_COCOA,
slouken@5056
   112
    SDL_SYSWM_UIKIT,
slouken@0
   113
} SDL_SYSWM_TYPE;
slouken@0
   114
slouken@3407
   115
/**
slouken@4900
   116
 *  The custom event structure.
slouken@3407
   117
 */
slouken@1895
   118
struct SDL_SysWMmsg
slouken@1895
   119
{
slouken@1895
   120
    SDL_version version;
slouken@1895
   121
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   122
    union
slouken@1895
   123
    {
slouken@5062
   124
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   125
        struct {
slouken@4900
   126
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   127
            UINT msg;                   /**< The type of message */
slouken@4900
   128
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   129
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   130
        } win;
slouken@5065
   131
#endif
slouken@5065
   132
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   133
        struct {
slouken@4900
   134
            XEvent event;
slouken@4900
   135
        } x11;
slouken@5065
   136
#endif
slouken@5065
   137
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   138
        struct {
slouken@4900
   139
            DFBEvent event;
slouken@4900
   140
        } dfb;
slouken@5065
   141
#endif
slouken@5065
   142
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   143
        struct
slouken@4900
   144
        {
slouken@4900
   145
            /* No Cocoa window events yet */
slouken@4900
   146
        } cocoa;
slouken@5065
   147
#endif
slouken@5065
   148
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   149
        struct
slouken@5056
   150
        {
slouken@5056
   151
            /* No UIKit window events yet */
slouken@5056
   152
        } uikit;
slouken@5065
   153
#endif
slouken@5063
   154
        /* Can't have an empty union */
slouken@5063
   155
        int dummy;
slouken@5056
   156
    } msg;
slouken@0
   157
};
slouken@0
   158
slouken@3407
   159
/**
slouken@4900
   160
 *  The custom window manager information structure.
slouken@3407
   161
 *
slouken@3407
   162
 *  When this structure is returned, it holds information about which
slouken@3407
   163
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   164
 */
slouken@1895
   165
struct SDL_SysWMinfo
slouken@1895
   166
{
slouken@1895
   167
    SDL_version version;
slouken@1895
   168
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   169
    union
slouken@1895
   170
    {
slouken@5062
   171
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   172
        struct
slouken@4900
   173
        {
slouken@4903
   174
            HWND window;                /**< The window handle */
slouken@4900
   175
        } win;
slouken@5065
   176
#endif
dludwig@8411
   177
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   178
        struct
dludwig@8411
   179
        {
dludwig@8463
   180
            IUnknown * window;          /**< The Windows RT CoreWindow */
dludwig@8411
   181
        } winrt;
dludwig@8411
   182
#endif
slouken@5065
   183
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   184
        struct
slouken@1895
   185
        {
slouken@4900
   186
            Display *display;           /**< The X11 display */
slouken@4903
   187
            Window window;              /**< The X11 window */
slouken@1895
   188
        } x11;
slouken@5065
   189
#endif
slouken@5065
   190
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   191
        struct
slouken@4899
   192
        {
slouken@4903
   193
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   194
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   195
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   196
        } dfb;
slouken@5065
   197
#endif
slouken@5065
   198
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   199
        struct
slouken@4900
   200
        {
slouken@4903
   201
            NSWindow *window;           /* The Cocoa window */
slouken@4900
   202
        } cocoa;
slouken@5065
   203
#endif
slouken@5065
   204
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   205
        struct
slouken@5056
   206
        {
slouken@5056
   207
            UIWindow *window;           /* The UIKit window */
dludwig@8305
   208
            UIViewController *viewcontroller;   /* The UIKit view controller */
slouken@5056
   209
        } uikit;
slouken@5065
   210
#endif
slouken@5063
   211
        /* Can't have an empty union */
slouken@5063
   212
        int dummy;
slouken@5056
   213
    } info;
slouken@1895
   214
};
slouken@0
   215
slouken@0
   216
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   217
slouken@1895
   218
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   219
slouken@0
   220
/* Function prototypes */
slouken@1895
   221
/**
slouken@3407
   222
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   223
 *
slouken@4530
   224
 *  \param window The window about which information is being requested
slouken@7191
   225
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   226
 *              then filled in with information about the given window.
slouken@7191
   227
 *
slouken@7191
   228
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   229
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   230
 *
slouken@3407
   231
 *  You typically use this function like this:
slouken@3407
   232
 *  \code
slouken@4895
   233
 *  SDL_SysWMinfo info;
slouken@3407
   234
 *  SDL_VERSION(&info.version);
slouken@7455
   235
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   236
 *  \endcode
slouken@0
   237
 */
slouken@3685
   238
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   239
                                                     SDL_SysWMinfo * info);
slouken@0
   240
slouken@0
   241
slouken@0
   242
/* Ends C function definitions when using C++ */
slouken@0
   243
#ifdef __cplusplus
slouken@0
   244
}
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: */