include/SDL_syswm.h
author Gabriel Jacobo <gabomdq@gmail.com>
Sat, 14 Dec 2013 20:18:43 -0300
changeset 8062 4fc5f66d63cc
parent 7455 0a988affc7e7
child 8134 7c9192be51a7
permissions -rw-r--r--
Wayland support

Based on the original port to Wayland by: Joel Teichroeb, Benjamin Franzke, Scott Moreau, et al.

Additional changes in this commit, done by me:

* Wayland uses the common EGL framework
* EGL can now create a desktop OpenGL context
* testgl2 loads GL functions dynamically, no need to link to libGL anymore
* Assorted fixes to the Wayland backend

Tested on the Weston Compositor (v1.0.5) that ships with Ubuntu 13.10,
running Weston under X. Tests ran: testrendercopyex (all backends), testgl2, testgles2,testintersections
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
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__
slouken@4900
    82
#include <Cocoa/Cocoa.h>
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;
slouken@5056
    93
#endif
slouken@5056
    94
#endif
slouken@5056
    95
slouken@7191
    96
/**
slouken@4900
    97
 *  These are the various supported windowing subsystems
slouken@3407
    98
 */
slouken@1895
    99
typedef enum
slouken@1895
   100
{
slouken@4900
   101
    SDL_SYSWM_UNKNOWN,
slouken@4900
   102
    SDL_SYSWM_WINDOWS,
slouken@4899
   103
    SDL_SYSWM_X11,
gabomdq@8062
   104
    SDL_SYSWM_WAYLAND,
slouken@4899
   105
    SDL_SYSWM_DIRECTFB,
slouken@4900
   106
    SDL_SYSWM_COCOA,
slouken@5056
   107
    SDL_SYSWM_UIKIT,
slouken@0
   108
} SDL_SYSWM_TYPE;
slouken@0
   109
slouken@3407
   110
/**
slouken@4900
   111
 *  The custom event structure.
slouken@3407
   112
 */
slouken@1895
   113
struct SDL_SysWMmsg
slouken@1895
   114
{
slouken@1895
   115
    SDL_version version;
slouken@1895
   116
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   117
    union
slouken@1895
   118
    {
slouken@5062
   119
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   120
        struct {
slouken@4900
   121
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   122
            UINT msg;                   /**< The type of message */
slouken@4900
   123
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   124
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   125
        } win;
slouken@5065
   126
#endif
slouken@5065
   127
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   128
        struct {
slouken@4900
   129
            XEvent event;
slouken@4900
   130
        } x11;
slouken@5065
   131
#endif
slouken@5065
   132
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   133
        struct {
slouken@4900
   134
            DFBEvent event;
slouken@4900
   135
        } dfb;
slouken@5065
   136
#endif
slouken@5065
   137
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   138
        struct
slouken@4900
   139
        {
slouken@4900
   140
            /* No Cocoa window events yet */
slouken@4900
   141
        } cocoa;
slouken@5065
   142
#endif
slouken@5065
   143
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   144
        struct
slouken@5056
   145
        {
slouken@5056
   146
            /* No UIKit window events yet */
slouken@5056
   147
        } uikit;
slouken@5065
   148
#endif
slouken@5063
   149
        /* Can't have an empty union */
slouken@5063
   150
        int dummy;
slouken@5056
   151
    } msg;
slouken@0
   152
};
slouken@0
   153
slouken@3407
   154
/**
slouken@4900
   155
 *  The custom window manager information structure.
slouken@3407
   156
 *
slouken@3407
   157
 *  When this structure is returned, it holds information about which
slouken@3407
   158
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   159
 */
slouken@1895
   160
struct SDL_SysWMinfo
slouken@1895
   161
{
slouken@1895
   162
    SDL_version version;
slouken@1895
   163
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   164
    union
slouken@1895
   165
    {
slouken@5062
   166
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   167
        struct
slouken@4900
   168
        {
slouken@4903
   169
            HWND window;                /**< The window handle */
slouken@4900
   170
        } win;
slouken@5065
   171
#endif
slouken@5065
   172
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   173
        struct
slouken@1895
   174
        {
slouken@4900
   175
            Display *display;           /**< The X11 display */
slouken@4903
   176
            Window window;              /**< The X11 window */
slouken@1895
   177
        } x11;
slouken@5065
   178
#endif
gabomdq@8062
   179
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
gabomdq@8062
   180
        struct
gabomdq@8062
   181
        {
gabomdq@8062
   182
            struct wl_display *display;            /**< Wayland display */
gabomdq@8062
   183
            struct wl_surface *surface;            /**< Wayland surface */
gabomdq@8062
   184
            struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
gabomdq@8062
   185
        } wl;
gabomdq@8062
   186
#endif
slouken@5065
   187
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   188
        struct
slouken@4899
   189
        {
slouken@4903
   190
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   191
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   192
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   193
        } dfb;
slouken@5065
   194
#endif
slouken@5065
   195
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   196
        struct
slouken@4900
   197
        {
slouken@4903
   198
            NSWindow *window;           /* The Cocoa window */
slouken@4900
   199
        } cocoa;
slouken@5065
   200
#endif
slouken@5065
   201
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   202
        struct
slouken@5056
   203
        {
slouken@5056
   204
            UIWindow *window;           /* The UIKit window */
slouken@5056
   205
        } uikit;
slouken@5065
   206
#endif
slouken@5063
   207
        /* Can't have an empty union */
slouken@5063
   208
        int dummy;
slouken@5056
   209
    } info;
slouken@1895
   210
};
slouken@0
   211
slouken@0
   212
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   213
slouken@1895
   214
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   215
slouken@0
   216
/* Function prototypes */
slouken@1895
   217
/**
slouken@3407
   218
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   219
 *
slouken@4530
   220
 *  \param window The window about which information is being requested
slouken@7191
   221
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   222
 *              then filled in with information about the given window.
slouken@7191
   223
 *
slouken@7191
   224
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   225
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   226
 *
slouken@3407
   227
 *  You typically use this function like this:
slouken@3407
   228
 *  \code
slouken@4895
   229
 *  SDL_SysWMinfo info;
slouken@3407
   230
 *  SDL_VERSION(&info.version);
slouken@7455
   231
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   232
 *  \endcode
slouken@0
   233
 */
slouken@3685
   234
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   235
                                                     SDL_SysWMinfo * info);
slouken@0
   236
slouken@0
   237
slouken@0
   238
/* Ends C function definitions when using C++ */
slouken@0
   239
#ifdef __cplusplus
slouken@0
   240
}
slouken@0
   241
#endif
slouken@0
   242
#include "close_code.h"
slouken@0
   243
slouken@0
   244
#endif /* _SDL_syswm_h */
slouken@1895
   245
slouken@1895
   246
/* vi: set ts=4 sw=4 expandtab: */