include/SDL_syswm.h
author Ryan C. Gordon <icculus@icculus.org>
Wed, 30 Jul 2014 14:14:19 -0400
changeset 9035 d6464107048c
parent 8968 47decd0106f8
child 9094 65a23b7b43c7
child 9510 e19faa3b5d88
permissions -rw-r--r--
Make SDL_SysWMinfo usable on Mac/iOS with ARC enabled (thanks, Alex!).

Fixes Bugzilla #2641.
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)
jorgen@8968
    55
#ifndef WIN32_LEAN_AND_MEAN
slouken@4900
    56
#define WIN32_LEAN_AND_MEAN
jorgen@8968
    57
#endif
slouken@4900
    58
#include <windows.h>
slouken@4900
    59
#endif
slouken@4900
    60
dludwig@8463
    61
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8527
    62
#include <Inspectable.h>
dludwig@8463
    63
#endif
dludwig@8463
    64
slouken@1361
    65
/* This is the structure for custom window manager events */
slouken@1626
    66
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    67
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    68
/* conflicts with Quickdraw.h */
icculus@1133
    69
#define Cursor X11Cursor
icculus@1133
    70
#endif
icculus@1133
    71
slouken@0
    72
#include <X11/Xlib.h>
slouken@0
    73
#include <X11/Xatom.h>
slouken@0
    74
icculus@1133
    75
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    76
/* matches the re-define above */
icculus@1133
    77
#undef Cursor
icculus@1133
    78
#endif
icculus@1133
    79
slouken@4899
    80
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
slouken@4899
    81
slouken@4899
    82
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@5199
    83
#include <directfb.h>
slouken@4899
    84
#endif
slouken@4900
    85
slouken@4900
    86
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
    87
#ifdef __OBJC__
jorgen@8812
    88
@class NSWindow;
slouken@4900
    89
#else
slouken@4900
    90
typedef struct _NSWindow NSWindow;
slouken@4900
    91
#endif
slouken@4900
    92
#endif
slouken@4900
    93
slouken@5056
    94
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
    95
#ifdef __OBJC__
slouken@5056
    96
#include <UIKit/UIKit.h>
slouken@5056
    97
#else
slouken@5056
    98
typedef struct _UIWindow UIWindow;
dludwig@8305
    99
typedef struct _UIViewController UIViewController;
slouken@5056
   100
#endif
slouken@5056
   101
#endif
slouken@5056
   102
slouken@8799
   103
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   104
typedef struct ANativeWindow ANativeWindow;
slouken@8799
   105
typedef void *EGLSurface;
slouken@8799
   106
#endif
slouken@8799
   107
slouken@7191
   108
/**
slouken@4900
   109
 *  These are the various supported windowing subsystems
slouken@3407
   110
 */
slouken@1895
   111
typedef enum
slouken@1895
   112
{
slouken@4900
   113
    SDL_SYSWM_UNKNOWN,
slouken@4900
   114
    SDL_SYSWM_WINDOWS,
slouken@4899
   115
    SDL_SYSWM_X11,
slouken@4899
   116
    SDL_SYSWM_DIRECTFB,
slouken@4900
   117
    SDL_SYSWM_COCOA,
slouken@5056
   118
    SDL_SYSWM_UIKIT,
gabomdq@8134
   119
    SDL_SYSWM_WAYLAND,
icculus@8153
   120
    SDL_SYSWM_MIR,
slouken@8799
   121
    SDL_SYSWM_WINRT,
slouken@8799
   122
    SDL_SYSWM_ANDROID
slouken@0
   123
} SDL_SYSWM_TYPE;
slouken@0
   124
slouken@3407
   125
/**
slouken@4900
   126
 *  The custom event structure.
slouken@3407
   127
 */
slouken@1895
   128
struct SDL_SysWMmsg
slouken@1895
   129
{
slouken@1895
   130
    SDL_version version;
slouken@1895
   131
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   132
    union
slouken@1895
   133
    {
slouken@5062
   134
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   135
        struct {
slouken@4900
   136
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   137
            UINT msg;                   /**< The type of message */
slouken@4900
   138
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   139
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   140
        } win;
slouken@5065
   141
#endif
slouken@5065
   142
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   143
        struct {
slouken@4900
   144
            XEvent event;
slouken@4900
   145
        } x11;
slouken@5065
   146
#endif
slouken@5065
   147
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   148
        struct {
slouken@4900
   149
            DFBEvent event;
slouken@4900
   150
        } dfb;
slouken@5065
   151
#endif
slouken@5065
   152
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   153
        struct
slouken@4900
   154
        {
slouken@4900
   155
            /* No Cocoa window events yet */
slouken@4900
   156
        } cocoa;
slouken@5065
   157
#endif
slouken@5065
   158
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   159
        struct
slouken@5056
   160
        {
slouken@5056
   161
            /* No UIKit window events yet */
slouken@5056
   162
        } uikit;
slouken@5065
   163
#endif
slouken@5063
   164
        /* Can't have an empty union */
slouken@5063
   165
        int dummy;
slouken@5056
   166
    } msg;
slouken@0
   167
};
slouken@0
   168
slouken@3407
   169
/**
slouken@4900
   170
 *  The custom window manager information structure.
slouken@3407
   171
 *
slouken@3407
   172
 *  When this structure is returned, it holds information about which
slouken@3407
   173
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   174
 */
slouken@1895
   175
struct SDL_SysWMinfo
slouken@1895
   176
{
slouken@1895
   177
    SDL_version version;
slouken@1895
   178
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   179
    union
slouken@1895
   180
    {
slouken@5062
   181
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   182
        struct
slouken@4900
   183
        {
slouken@4903
   184
            HWND window;                /**< The window handle */
slouken@4900
   185
        } win;
slouken@5065
   186
#endif
dludwig@8411
   187
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   188
        struct
dludwig@8411
   189
        {
dludwig@8527
   190
            IInspectable * window;      /**< The WinRT CoreWindow */
dludwig@8411
   191
        } winrt;
dludwig@8411
   192
#endif
slouken@5065
   193
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   194
        struct
slouken@1895
   195
        {
slouken@4900
   196
            Display *display;           /**< The X11 display */
slouken@4903
   197
            Window window;              /**< The X11 window */
slouken@1895
   198
        } x11;
slouken@5065
   199
#endif
slouken@5065
   200
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   201
        struct
slouken@4899
   202
        {
slouken@4903
   203
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   204
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   205
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   206
        } dfb;
slouken@5065
   207
#endif
slouken@5065
   208
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   209
        struct
slouken@4900
   210
        {
icculus@9035
   211
#if defined(__OBJC__) && __has_feature(objc_arc)
icculus@9035
   212
            NSWindow __unsafe_unretained *window; /* The Cocoa window */
icculus@9035
   213
#else
icculus@9035
   214
            NSWindow *window;                     /* The Cocoa window */
icculus@9035
   215
#endif
slouken@4900
   216
        } cocoa;
slouken@5065
   217
#endif
slouken@5065
   218
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   219
        struct
slouken@5056
   220
        {
icculus@9035
   221
#if defined(__OBJC__) && __has_feature(objc_arc)
icculus@9035
   222
            UIWindow __unsafe_unretained *window; /* The UIKit window */
icculus@9035
   223
#else
icculus@9035
   224
            UIWindow *window;                     /* The UIKit window */
icculus@9035
   225
#endif
slouken@5056
   226
        } uikit;
slouken@5065
   227
#endif
gabomdq@8134
   228
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
gabomdq@8134
   229
        struct
gabomdq@8134
   230
        {
gabomdq@8134
   231
            struct wl_display *display;            /**< Wayland display */
gabomdq@8134
   232
            struct wl_surface *surface;            /**< Wayland surface */
gabomdq@8134
   233
            struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
gabomdq@8134
   234
        } wl;
gabomdq@8134
   235
#endif
icculus@8155
   236
#if defined(SDL_VIDEO_DRIVER_MIR)
icculus@8155
   237
        struct
icculus@8155
   238
        {
brandon@8731
   239
            struct MirConnection *connection;  /**< Mir display server connection */
brandon@8731
   240
            struct MirSurface *surface;  /**< Mir surface */
icculus@8155
   241
        } mir;
icculus@8155
   242
#endif
icculus@8155
   243
slouken@8799
   244
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   245
        struct
slouken@8799
   246
        {
slouken@8799
   247
            ANativeWindow *window;
slouken@8799
   248
            EGLSurface surface;
slouken@8799
   249
        } android;
slouken@8799
   250
#endif
slouken@8799
   251
slouken@5063
   252
        /* Can't have an empty union */
slouken@5063
   253
        int dummy;
slouken@5056
   254
    } info;
slouken@1895
   255
};
slouken@0
   256
slouken@0
   257
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   258
slouken@1895
   259
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   260
slouken@0
   261
/* Function prototypes */
slouken@1895
   262
/**
slouken@3407
   263
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   264
 *
slouken@4530
   265
 *  \param window The window about which information is being requested
slouken@7191
   266
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   267
 *              then filled in with information about the given window.
slouken@7191
   268
 *
slouken@7191
   269
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   270
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   271
 *
slouken@3407
   272
 *  You typically use this function like this:
slouken@3407
   273
 *  \code
slouken@4895
   274
 *  SDL_SysWMinfo info;
slouken@3407
   275
 *  SDL_VERSION(&info.version);
slouken@7455
   276
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   277
 *  \endcode
slouken@0
   278
 */
slouken@3685
   279
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   280
                                                     SDL_SysWMinfo * info);
slouken@0
   281
slouken@0
   282
slouken@0
   283
/* Ends C function definitions when using C++ */
slouken@0
   284
#ifdef __cplusplus
slouken@0
   285
}
slouken@0
   286
#endif
slouken@0
   287
#include "close_code.h"
slouken@0
   288
slouken@0
   289
#endif /* _SDL_syswm_h */
slouken@1895
   290
slouken@1895
   291
/* vi: set ts=4 sw=4 expandtab: */