include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 10 Mar 2014 19:11:52 -0700
changeset 8603 fef61d2fd948
parent 8583 fb2933ca805f
child 8731 ede9d13dad21
permissions -rw-r--r--
Fixed binary compatibility with the new Windows RT support
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 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@8527
    60
#include <Inspectable.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
icculus@8155
   101
#if defined(SDL_VIDEO_DRIVER_MIR)
icculus@8155
   102
#include <mir_toolkit/mir_client_library.h>
icculus@8155
   103
#endif
icculus@8155
   104
icculus@8155
   105
slouken@7191
   106
/**
slouken@4900
   107
 *  These are the various supported windowing subsystems
slouken@3407
   108
 */
slouken@1895
   109
typedef enum
slouken@1895
   110
{
slouken@4900
   111
    SDL_SYSWM_UNKNOWN,
slouken@4900
   112
    SDL_SYSWM_WINDOWS,
slouken@4899
   113
    SDL_SYSWM_X11,
slouken@4899
   114
    SDL_SYSWM_DIRECTFB,
slouken@4900
   115
    SDL_SYSWM_COCOA,
slouken@5056
   116
    SDL_SYSWM_UIKIT,
gabomdq@8134
   117
    SDL_SYSWM_WAYLAND,
icculus@8153
   118
    SDL_SYSWM_MIR,
slouken@8603
   119
    SDL_SYSWM_WINRT,
slouken@0
   120
} SDL_SYSWM_TYPE;
slouken@0
   121
slouken@3407
   122
/**
slouken@4900
   123
 *  The custom event structure.
slouken@3407
   124
 */
slouken@1895
   125
struct SDL_SysWMmsg
slouken@1895
   126
{
slouken@1895
   127
    SDL_version version;
slouken@1895
   128
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   129
    union
slouken@1895
   130
    {
slouken@5062
   131
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   132
        struct {
slouken@4900
   133
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   134
            UINT msg;                   /**< The type of message */
slouken@4900
   135
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   136
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   137
        } win;
slouken@5065
   138
#endif
slouken@5065
   139
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   140
        struct {
slouken@4900
   141
            XEvent event;
slouken@4900
   142
        } x11;
slouken@5065
   143
#endif
slouken@5065
   144
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   145
        struct {
slouken@4900
   146
            DFBEvent event;
slouken@4900
   147
        } dfb;
slouken@5065
   148
#endif
slouken@5065
   149
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   150
        struct
slouken@4900
   151
        {
slouken@4900
   152
            /* No Cocoa window events yet */
slouken@4900
   153
        } cocoa;
slouken@5065
   154
#endif
slouken@5065
   155
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   156
        struct
slouken@5056
   157
        {
slouken@5056
   158
            /* No UIKit window events yet */
slouken@5056
   159
        } uikit;
slouken@5065
   160
#endif
slouken@5063
   161
        /* Can't have an empty union */
slouken@5063
   162
        int dummy;
slouken@5056
   163
    } msg;
slouken@0
   164
};
slouken@0
   165
slouken@3407
   166
/**
slouken@4900
   167
 *  The custom window manager information structure.
slouken@3407
   168
 *
slouken@3407
   169
 *  When this structure is returned, it holds information about which
slouken@3407
   170
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   171
 */
slouken@1895
   172
struct SDL_SysWMinfo
slouken@1895
   173
{
slouken@1895
   174
    SDL_version version;
slouken@1895
   175
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   176
    union
slouken@1895
   177
    {
slouken@5062
   178
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   179
        struct
slouken@4900
   180
        {
slouken@4903
   181
            HWND window;                /**< The window handle */
slouken@4900
   182
        } win;
slouken@5065
   183
#endif
dludwig@8411
   184
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   185
        struct
dludwig@8411
   186
        {
dludwig@8527
   187
            IInspectable * window;      /**< The WinRT CoreWindow */
dludwig@8411
   188
        } winrt;
dludwig@8411
   189
#endif
slouken@5065
   190
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   191
        struct
slouken@1895
   192
        {
slouken@4900
   193
            Display *display;           /**< The X11 display */
slouken@4903
   194
            Window window;              /**< The X11 window */
slouken@1895
   195
        } x11;
slouken@5065
   196
#endif
slouken@5065
   197
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   198
        struct
slouken@4899
   199
        {
slouken@4903
   200
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   201
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   202
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   203
        } dfb;
slouken@5065
   204
#endif
slouken@5065
   205
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   206
        struct
slouken@4900
   207
        {
slouken@4903
   208
            NSWindow *window;           /* The Cocoa window */
slouken@4900
   209
        } cocoa;
slouken@5065
   210
#endif
slouken@5065
   211
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   212
        struct
slouken@5056
   213
        {
slouken@5056
   214
            UIWindow *window;           /* The UIKit window */
slouken@5056
   215
        } uikit;
slouken@5065
   216
#endif
gabomdq@8134
   217
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
gabomdq@8134
   218
        struct
gabomdq@8134
   219
        {
gabomdq@8134
   220
            struct wl_display *display;            /**< Wayland display */
gabomdq@8134
   221
            struct wl_surface *surface;            /**< Wayland surface */
gabomdq@8134
   222
            struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
gabomdq@8134
   223
        } wl;
gabomdq@8134
   224
#endif
icculus@8155
   225
#if defined(SDL_VIDEO_DRIVER_MIR)
icculus@8155
   226
        struct
icculus@8155
   227
        {
icculus@8155
   228
            MirConnection *connection;  /**< Mir display server connection */
icculus@8155
   229
            MirSurface *surface;  /**< Mir surface */
icculus@8155
   230
        } mir;
icculus@8155
   231
#endif
icculus@8155
   232
slouken@5063
   233
        /* Can't have an empty union */
slouken@5063
   234
        int dummy;
slouken@5056
   235
    } info;
slouken@1895
   236
};
slouken@0
   237
slouken@0
   238
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   239
slouken@1895
   240
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   241
slouken@0
   242
/* Function prototypes */
slouken@1895
   243
/**
slouken@3407
   244
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   245
 *
slouken@4530
   246
 *  \param window The window about which information is being requested
slouken@7191
   247
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   248
 *              then filled in with information about the given window.
slouken@7191
   249
 *
slouken@7191
   250
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   251
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   252
 *
slouken@3407
   253
 *  You typically use this function like this:
slouken@3407
   254
 *  \code
slouken@4895
   255
 *  SDL_SysWMinfo info;
slouken@3407
   256
 *  SDL_VERSION(&info.version);
slouken@7455
   257
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   258
 *  \endcode
slouken@0
   259
 */
slouken@3685
   260
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   261
                                                     SDL_SysWMinfo * info);
slouken@0
   262
slouken@0
   263
slouken@0
   264
/* Ends C function definitions when using C++ */
slouken@0
   265
#ifdef __cplusplus
slouken@0
   266
}
slouken@0
   267
#endif
slouken@0
   268
#include "close_code.h"
slouken@0
   269
slouken@0
   270
#endif /* _SDL_syswm_h */
slouken@1895
   271
slouken@1895
   272
/* vi: set ts=4 sw=4 expandtab: */