include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 23 May 2019 14:19:00 -0700
changeset 12756 4116bf232fe7
parent 12503 806492103856
permissions -rw-r--r--
Added a function to get the current Android SDK version at runtime
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@12503
     3
  Copyright (C) 1997-2019 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@10638
    28
#ifndef SDL_syswm_h_
slouken@10638
    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@3407
    36
/**
sylvain@12454
    37
 *  \brief SDL_syswm.h
slouken@7191
    38
 *
slouken@3407
    39
 *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
slouken@3407
    40
 *  which contains window-manager specific information and arrives whenever
slouken@3407
    41
 *  an unhandled window event occurs.  This event is ignored by default, but
slouken@3407
    42
 *  you can enable it with SDL_EventState().
slouken@3407
    43
 */
slouken@0
    44
struct SDL_SysWMinfo;
sezeroz@12397
    45
sezeroz@12397
    46
#if !defined(SDL_PROTOTYPES_ONLY)
slouken@0
    47
slouken@5062
    48
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
jorgen@8968
    49
#ifndef WIN32_LEAN_AND_MEAN
slouken@4900
    50
#define WIN32_LEAN_AND_MEAN
jorgen@8968
    51
#endif
slouken@4900
    52
#include <windows.h>
slouken@4900
    53
#endif
slouken@4900
    54
dludwig@8463
    55
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8527
    56
#include <Inspectable.h>
dludwig@8463
    57
#endif
dludwig@8463
    58
slouken@1361
    59
/* This is the structure for custom window manager events */
slouken@1626
    60
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    61
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    62
/* conflicts with Quickdraw.h */
icculus@1133
    63
#define Cursor X11Cursor
icculus@1133
    64
#endif
icculus@1133
    65
slouken@0
    66
#include <X11/Xlib.h>
slouken@0
    67
#include <X11/Xatom.h>
slouken@0
    68
icculus@1133
    69
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    70
/* matches the re-define above */
icculus@1133
    71
#undef Cursor
icculus@1133
    72
#endif
icculus@1133
    73
slouken@4899
    74
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
slouken@4899
    75
slouken@4899
    76
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@5199
    77
#include <directfb.h>
slouken@4899
    78
#endif
slouken@4900
    79
slouken@4900
    80
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
    81
#ifdef __OBJC__
jorgen@8812
    82
@class NSWindow;
slouken@4900
    83
#else
slouken@4900
    84
typedef struct _NSWindow NSWindow;
slouken@4900
    85
#endif
slouken@4900
    86
#endif
slouken@4900
    87
slouken@5056
    88
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
    89
#ifdef __OBJC__
slouken@5056
    90
#include <UIKit/UIKit.h>
slouken@5056
    91
#else
slouken@5056
    92
typedef struct _UIWindow UIWindow;
dludwig@8305
    93
typedef struct _UIViewController UIViewController;
slouken@5056
    94
#endif
slime73@9540
    95
typedef Uint32 GLuint;
slouken@5056
    96
#endif
slouken@5056
    97
slouken@8799
    98
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
    99
typedef struct ANativeWindow ANativeWindow;
slouken@8799
   100
typedef void *EGLSurface;
slouken@8799
   101
#endif
slouken@8799
   102
slouken@10055
   103
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
slouken@10055
   104
#include "SDL_egl.h"
slouken@10055
   105
#endif
sezeroz@12397
   106
#endif /* SDL_PROTOTYPES_ONLY */
sezeroz@12397
   107
slouken@10055
   108
slouken@11957
   109
#include "begin_code.h"
slouken@11957
   110
/* Set up for C function definitions, even when using C++ */
slouken@11957
   111
#ifdef __cplusplus
slouken@11957
   112
extern "C" {
slouken@11957
   113
#endif
slouken@11957
   114
sezeroz@12397
   115
#if !defined(SDL_PROTOTYPES_ONLY)
slouken@7191
   116
/**
slouken@4900
   117
 *  These are the various supported windowing subsystems
slouken@3407
   118
 */
slouken@1895
   119
typedef enum
slouken@1895
   120
{
slouken@4900
   121
    SDL_SYSWM_UNKNOWN,
slouken@4900
   122
    SDL_SYSWM_WINDOWS,
slouken@4899
   123
    SDL_SYSWM_X11,
slouken@4899
   124
    SDL_SYSWM_DIRECTFB,
slouken@4900
   125
    SDL_SYSWM_COCOA,
slouken@5056
   126
    SDL_SYSWM_UIKIT,
gabomdq@8134
   127
    SDL_SYSWM_WAYLAND,
icculus@12391
   128
    SDL_SYSWM_MIR,  /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
slouken@8799
   129
    SDL_SYSWM_WINRT,
slouken@10055
   130
    SDL_SYSWM_ANDROID,
slouken@11287
   131
    SDL_SYSWM_VIVANTE,
slouken@11287
   132
    SDL_SYSWM_OS2
slouken@0
   133
} SDL_SYSWM_TYPE;
slouken@0
   134
slouken@3407
   135
/**
slouken@4900
   136
 *  The custom event structure.
slouken@3407
   137
 */
slouken@1895
   138
struct SDL_SysWMmsg
slouken@1895
   139
{
slouken@1895
   140
    SDL_version version;
slouken@1895
   141
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   142
    union
slouken@1895
   143
    {
slouken@5062
   144
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   145
        struct {
slouken@4900
   146
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   147
            UINT msg;                   /**< The type of message */
slouken@4900
   148
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   149
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   150
        } win;
slouken@5065
   151
#endif
slouken@5065
   152
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   153
        struct {
slouken@4900
   154
            XEvent event;
slouken@4900
   155
        } x11;
slouken@5065
   156
#endif
slouken@5065
   157
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   158
        struct {
slouken@4900
   159
            DFBEvent event;
slouken@4900
   160
        } dfb;
slouken@5065
   161
#endif
slouken@5065
   162
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   163
        struct
slouken@4900
   164
        {
jorgen@9153
   165
            /* Latest version of Xcode clang complains about empty structs in C v. C++:
jorgen@9153
   166
                 error: empty struct has size 0 in C, size 1 in C++
jorgen@9153
   167
             */
jorgen@9153
   168
            int dummy;
slouken@4900
   169
            /* No Cocoa window events yet */
slouken@4900
   170
        } cocoa;
slouken@5065
   171
#endif
slouken@5065
   172
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   173
        struct
slouken@5056
   174
        {
slime73@9586
   175
            int dummy;
slouken@5056
   176
            /* No UIKit window events yet */
slouken@5056
   177
        } uikit;
slouken@5065
   178
#endif
slouken@10055
   179
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
slouken@10055
   180
        struct
slouken@10055
   181
        {
slouken@10055
   182
            int dummy;
slouken@10055
   183
            /* No Vivante window events yet */
slouken@10055
   184
        } vivante;
slouken@10055
   185
#endif
slouken@5063
   186
        /* Can't have an empty union */
slouken@5063
   187
        int dummy;
slouken@5056
   188
    } msg;
slouken@0
   189
};
slouken@0
   190
slouken@3407
   191
/**
slouken@4900
   192
 *  The custom window manager information structure.
slouken@3407
   193
 *
slouken@3407
   194
 *  When this structure is returned, it holds information about which
slouken@3407
   195
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   196
 */
slouken@1895
   197
struct SDL_SysWMinfo
slouken@1895
   198
{
slouken@1895
   199
    SDL_version version;
slouken@1895
   200
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   201
    union
slouken@1895
   202
    {
slouken@5062
   203
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   204
        struct
slouken@4900
   205
        {
slouken@4903
   206
            HWND window;                /**< The window handle */
icculus@9422
   207
            HDC hdc;                    /**< The window device context */
slouken@10634
   208
            HINSTANCE hinstance;        /**< The instance handle */
slouken@4900
   209
        } win;
slouken@5065
   210
#endif
dludwig@8411
   211
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   212
        struct
dludwig@8411
   213
        {
dludwig@8527
   214
            IInspectable * window;      /**< The WinRT CoreWindow */
dludwig@8411
   215
        } winrt;
dludwig@8411
   216
#endif
slouken@5065
   217
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   218
        struct
slouken@1895
   219
        {
slouken@4900
   220
            Display *display;           /**< The X11 display */
slouken@4903
   221
            Window window;              /**< The X11 window */
slouken@1895
   222
        } x11;
slouken@5065
   223
#endif
slouken@5065
   224
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   225
        struct
slouken@4899
   226
        {
slouken@4903
   227
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   228
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   229
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   230
        } dfb;
slouken@5065
   231
#endif
slouken@5065
   232
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   233
        struct
slouken@4900
   234
        {
slouken@9099
   235
#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
philipp@11065
   236
            NSWindow __unsafe_unretained *window; /**< The Cocoa window */
icculus@9035
   237
#else
philipp@11065
   238
            NSWindow *window;                     /**< The Cocoa window */
icculus@9035
   239
#endif
slouken@4900
   240
        } cocoa;
slouken@5065
   241
#endif
slouken@5065
   242
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   243
        struct
slouken@5056
   244
        {
slouken@9099
   245
#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
philipp@11065
   246
            UIWindow __unsafe_unretained *window; /**< The UIKit window */
icculus@9035
   247
#else
philipp@11065
   248
            UIWindow *window;                     /**< The UIKit window */
icculus@9035
   249
#endif
philipp@11065
   250
            GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
philipp@11065
   251
            GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
philipp@11065
   252
            GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
slouken@5056
   253
        } uikit;
slouken@5065
   254
#endif
gabomdq@8134
   255
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
gabomdq@8134
   256
        struct
gabomdq@8134
   257
        {
gabomdq@8134
   258
            struct wl_display *display;            /**< Wayland display */
gabomdq@8134
   259
            struct wl_surface *surface;            /**< Wayland surface */
gabomdq@8134
   260
            struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
gabomdq@8134
   261
        } wl;
gabomdq@8134
   262
#endif
icculus@12391
   263
#if defined(SDL_VIDEO_DRIVER_MIR)  /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
icculus@8155
   264
        struct
icculus@8155
   265
        {
icculus@12391
   266
            void *connection;  /**< Mir display server connection */
icculus@12391
   267
            void *surface;  /**< Mir surface */
icculus@8155
   268
        } mir;
icculus@8155
   269
#endif
icculus@8155
   270
slouken@8799
   271
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   272
        struct
slouken@8799
   273
        {
slouken@8799
   274
            ANativeWindow *window;
slouken@8799
   275
            EGLSurface surface;
slouken@8799
   276
        } android;
slouken@8799
   277
#endif
slouken@8799
   278
slouken@10055
   279
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
slouken@10055
   280
        struct
slouken@10055
   281
        {
slouken@10055
   282
            EGLNativeDisplayType display;
slouken@10055
   283
            EGLNativeWindowType window;
slouken@10055
   284
        } vivante;
slouken@10055
   285
#endif
slouken@10055
   286
icculus@11088
   287
        /* Make sure this union is always 64 bytes (8 64-bit pointers). */
icculus@11088
   288
        /* Be careful not to overflow this if you add a new target! */
icculus@11088
   289
        Uint8 dummy[64];
slouken@5056
   290
    } info;
slouken@1895
   291
};
slouken@0
   292
slouken@0
   293
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   294
slouken@1895
   295
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   296
slouken@0
   297
/* Function prototypes */
slouken@1895
   298
/**
slouken@3407
   299
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   300
 *
slouken@4530
   301
 *  \param window The window about which information is being requested
slouken@7191
   302
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   303
 *              then filled in with information about the given window.
slouken@7191
   304
 *
slouken@7191
   305
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   306
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   307
 *
slouken@3407
   308
 *  You typically use this function like this:
slouken@3407
   309
 *  \code
slouken@4895
   310
 *  SDL_SysWMinfo info;
slouken@3407
   311
 *  SDL_VERSION(&info.version);
slouken@7455
   312
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   313
 *  \endcode
slouken@0
   314
 */
slouken@3685
   315
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   316
                                                     SDL_SysWMinfo * info);
slouken@0
   317
slouken@0
   318
slouken@0
   319
/* Ends C function definitions when using C++ */
slouken@0
   320
#ifdef __cplusplus
slouken@0
   321
}
slouken@0
   322
#endif
slouken@0
   323
#include "close_code.h"
slouken@0
   324
slouken@10638
   325
#endif /* SDL_syswm_h_ */
slouken@1895
   326
slouken@1895
   327
/* vi: set ts=4 sw=4 expandtab: */