include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 26 May 2015 06:27:46 -0700
changeset 9619 b94b6d0bff0f
parent 9586 037074526d4c
child 9810 1e079120100e
permissions -rw-r--r--
Updated the copyright year to 2015
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 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
slime73@9540
   101
typedef Uint32 GLuint;
slouken@5056
   102
#endif
slouken@5056
   103
slouken@8799
   104
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   105
typedef struct ANativeWindow ANativeWindow;
slouken@8799
   106
typedef void *EGLSurface;
slouken@8799
   107
#endif
slouken@8799
   108
slouken@7191
   109
/**
slouken@4900
   110
 *  These are the various supported windowing subsystems
slouken@3407
   111
 */
slouken@1895
   112
typedef enum
slouken@1895
   113
{
slouken@4900
   114
    SDL_SYSWM_UNKNOWN,
slouken@4900
   115
    SDL_SYSWM_WINDOWS,
slouken@4899
   116
    SDL_SYSWM_X11,
slouken@4899
   117
    SDL_SYSWM_DIRECTFB,
slouken@4900
   118
    SDL_SYSWM_COCOA,
slouken@5056
   119
    SDL_SYSWM_UIKIT,
gabomdq@8134
   120
    SDL_SYSWM_WAYLAND,
icculus@8153
   121
    SDL_SYSWM_MIR,
slouken@8799
   122
    SDL_SYSWM_WINRT,
slouken@8799
   123
    SDL_SYSWM_ANDROID
slouken@0
   124
} SDL_SYSWM_TYPE;
slouken@0
   125
slouken@3407
   126
/**
slouken@4900
   127
 *  The custom event structure.
slouken@3407
   128
 */
slouken@1895
   129
struct SDL_SysWMmsg
slouken@1895
   130
{
slouken@1895
   131
    SDL_version version;
slouken@1895
   132
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   133
    union
slouken@1895
   134
    {
slouken@5062
   135
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   136
        struct {
slouken@4900
   137
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   138
            UINT msg;                   /**< The type of message */
slouken@4900
   139
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   140
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   141
        } win;
slouken@5065
   142
#endif
slouken@5065
   143
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   144
        struct {
slouken@4900
   145
            XEvent event;
slouken@4900
   146
        } x11;
slouken@5065
   147
#endif
slouken@5065
   148
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   149
        struct {
slouken@4900
   150
            DFBEvent event;
slouken@4900
   151
        } dfb;
slouken@5065
   152
#endif
slouken@5065
   153
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   154
        struct
slouken@4900
   155
        {
jorgen@9153
   156
            /* Latest version of Xcode clang complains about empty structs in C v. C++:
jorgen@9153
   157
                 error: empty struct has size 0 in C, size 1 in C++
jorgen@9153
   158
             */
jorgen@9153
   159
            int dummy;
slouken@4900
   160
            /* No Cocoa window events yet */
slouken@4900
   161
        } cocoa;
slouken@5065
   162
#endif
slouken@5065
   163
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   164
        struct
slouken@5056
   165
        {
slime73@9586
   166
            int dummy;
slouken@5056
   167
            /* No UIKit window events yet */
slouken@5056
   168
        } uikit;
slouken@5065
   169
#endif
slouken@5063
   170
        /* Can't have an empty union */
slouken@5063
   171
        int dummy;
slouken@5056
   172
    } msg;
slouken@0
   173
};
slouken@0
   174
slouken@3407
   175
/**
slouken@4900
   176
 *  The custom window manager information structure.
slouken@3407
   177
 *
slouken@3407
   178
 *  When this structure is returned, it holds information about which
slouken@3407
   179
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   180
 */
slouken@1895
   181
struct SDL_SysWMinfo
slouken@1895
   182
{
slouken@1895
   183
    SDL_version version;
slouken@1895
   184
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   185
    union
slouken@1895
   186
    {
slouken@5062
   187
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   188
        struct
slouken@4900
   189
        {
slouken@4903
   190
            HWND window;                /**< The window handle */
icculus@9422
   191
            HDC hdc;                    /**< The window device context */
slouken@4900
   192
        } win;
slouken@5065
   193
#endif
dludwig@8411
   194
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   195
        struct
dludwig@8411
   196
        {
dludwig@8527
   197
            IInspectable * window;      /**< The WinRT CoreWindow */
dludwig@8411
   198
        } winrt;
dludwig@8411
   199
#endif
slouken@5065
   200
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   201
        struct
slouken@1895
   202
        {
slouken@4900
   203
            Display *display;           /**< The X11 display */
slouken@4903
   204
            Window window;              /**< The X11 window */
slouken@1895
   205
        } x11;
slouken@5065
   206
#endif
slouken@5065
   207
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   208
        struct
slouken@4899
   209
        {
slouken@4903
   210
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   211
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   212
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   213
        } dfb;
slouken@5065
   214
#endif
slouken@5065
   215
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   216
        struct
slouken@4900
   217
        {
slouken@9099
   218
#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
icculus@9035
   219
            NSWindow __unsafe_unretained *window; /* The Cocoa window */
icculus@9035
   220
#else
icculus@9035
   221
            NSWindow *window;                     /* The Cocoa window */
icculus@9035
   222
#endif
slouken@4900
   223
        } cocoa;
slouken@5065
   224
#endif
slouken@5065
   225
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   226
        struct
slouken@5056
   227
        {
slouken@9099
   228
#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
icculus@9035
   229
            UIWindow __unsafe_unretained *window; /* The UIKit window */
icculus@9035
   230
#else
icculus@9035
   231
            UIWindow *window;                     /* The UIKit window */
icculus@9035
   232
#endif
slime73@9540
   233
            GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
slime73@9540
   234
            GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
slouken@5056
   235
        } uikit;
slouken@5065
   236
#endif
gabomdq@8134
   237
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
gabomdq@8134
   238
        struct
gabomdq@8134
   239
        {
gabomdq@8134
   240
            struct wl_display *display;            /**< Wayland display */
gabomdq@8134
   241
            struct wl_surface *surface;            /**< Wayland surface */
gabomdq@8134
   242
            struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
gabomdq@8134
   243
        } wl;
gabomdq@8134
   244
#endif
icculus@8155
   245
#if defined(SDL_VIDEO_DRIVER_MIR)
icculus@8155
   246
        struct
icculus@8155
   247
        {
brandon@8731
   248
            struct MirConnection *connection;  /**< Mir display server connection */
brandon@8731
   249
            struct MirSurface *surface;  /**< Mir surface */
icculus@8155
   250
        } mir;
icculus@8155
   251
#endif
icculus@8155
   252
slouken@8799
   253
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   254
        struct
slouken@8799
   255
        {
slouken@8799
   256
            ANativeWindow *window;
slouken@8799
   257
            EGLSurface surface;
slouken@8799
   258
        } android;
slouken@8799
   259
#endif
slouken@8799
   260
slouken@5063
   261
        /* Can't have an empty union */
slouken@5063
   262
        int dummy;
slouken@5056
   263
    } info;
slouken@1895
   264
};
slouken@0
   265
slouken@0
   266
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   267
slouken@1895
   268
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   269
slouken@0
   270
/* Function prototypes */
slouken@1895
   271
/**
slouken@3407
   272
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   273
 *
slouken@4530
   274
 *  \param window The window about which information is being requested
slouken@7191
   275
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   276
 *              then filled in with information about the given window.
slouken@7191
   277
 *
slouken@7191
   278
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   279
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   280
 *
slouken@3407
   281
 *  You typically use this function like this:
slouken@3407
   282
 *  \code
slouken@4895
   283
 *  SDL_SysWMinfo info;
slouken@3407
   284
 *  SDL_VERSION(&info.version);
slouken@7455
   285
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   286
 *  \endcode
slouken@0
   287
 */
slouken@3685
   288
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   289
                                                     SDL_SysWMinfo * info);
slouken@0
   290
slouken@0
   291
slouken@0
   292
/* Ends C function definitions when using C++ */
slouken@0
   293
#ifdef __cplusplus
slouken@0
   294
}
slouken@0
   295
#endif
slouken@0
   296
#include "close_code.h"
slouken@0
   297
slouken@0
   298
#endif /* _SDL_syswm_h */
slouken@1895
   299
slouken@1895
   300
/* vi: set ts=4 sw=4 expandtab: */