include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 14 Jul 2013 11:57:01 -0700
changeset 7455 0a988affc7e7
parent 7282 df78adc8ba04
child 8062 4fc5f66d63cc
child 8477 ad08f0d710f3
permissions -rw-r--r--
Fixed code example for SDL_GetWindowWMInfo()
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,
slouken@4899
   104
    SDL_SYSWM_DIRECTFB,
slouken@4900
   105
    SDL_SYSWM_COCOA,
slouken@5056
   106
    SDL_SYSWM_UIKIT,
slouken@0
   107
} SDL_SYSWM_TYPE;
slouken@0
   108
slouken@3407
   109
/**
slouken@4900
   110
 *  The custom event structure.
slouken@3407
   111
 */
slouken@1895
   112
struct SDL_SysWMmsg
slouken@1895
   113
{
slouken@1895
   114
    SDL_version version;
slouken@1895
   115
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   116
    union
slouken@1895
   117
    {
slouken@5062
   118
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   119
        struct {
slouken@4900
   120
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   121
            UINT msg;                   /**< The type of message */
slouken@4900
   122
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   123
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   124
        } win;
slouken@5065
   125
#endif
slouken@5065
   126
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   127
        struct {
slouken@4900
   128
            XEvent event;
slouken@4900
   129
        } x11;
slouken@5065
   130
#endif
slouken@5065
   131
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   132
        struct {
slouken@4900
   133
            DFBEvent event;
slouken@4900
   134
        } dfb;
slouken@5065
   135
#endif
slouken@5065
   136
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   137
        struct
slouken@4900
   138
        {
slouken@4900
   139
            /* No Cocoa window events yet */
slouken@4900
   140
        } cocoa;
slouken@5065
   141
#endif
slouken@5065
   142
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   143
        struct
slouken@5056
   144
        {
slouken@5056
   145
            /* No UIKit window events yet */
slouken@5056
   146
        } uikit;
slouken@5065
   147
#endif
slouken@5063
   148
        /* Can't have an empty union */
slouken@5063
   149
        int dummy;
slouken@5056
   150
    } msg;
slouken@0
   151
};
slouken@0
   152
slouken@3407
   153
/**
slouken@4900
   154
 *  The custom window manager information structure.
slouken@3407
   155
 *
slouken@3407
   156
 *  When this structure is returned, it holds information about which
slouken@3407
   157
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   158
 */
slouken@1895
   159
struct SDL_SysWMinfo
slouken@1895
   160
{
slouken@1895
   161
    SDL_version version;
slouken@1895
   162
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   163
    union
slouken@1895
   164
    {
slouken@5062
   165
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   166
        struct
slouken@4900
   167
        {
slouken@4903
   168
            HWND window;                /**< The window handle */
slouken@4900
   169
        } win;
slouken@5065
   170
#endif
slouken@5065
   171
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   172
        struct
slouken@1895
   173
        {
slouken@4900
   174
            Display *display;           /**< The X11 display */
slouken@4903
   175
            Window window;              /**< The X11 window */
slouken@1895
   176
        } x11;
slouken@5065
   177
#endif
slouken@5065
   178
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   179
        struct
slouken@4899
   180
        {
slouken@4903
   181
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   182
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   183
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   184
        } dfb;
slouken@5065
   185
#endif
slouken@5065
   186
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   187
        struct
slouken@4900
   188
        {
slouken@4903
   189
            NSWindow *window;           /* The Cocoa window */
slouken@4900
   190
        } cocoa;
slouken@5065
   191
#endif
slouken@5065
   192
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   193
        struct
slouken@5056
   194
        {
slouken@5056
   195
            UIWindow *window;           /* The UIKit window */
slouken@5056
   196
        } uikit;
slouken@5065
   197
#endif
slouken@5063
   198
        /* Can't have an empty union */
slouken@5063
   199
        int dummy;
slouken@5056
   200
    } info;
slouken@1895
   201
};
slouken@0
   202
slouken@0
   203
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   204
slouken@1895
   205
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   206
slouken@0
   207
/* Function prototypes */
slouken@1895
   208
/**
slouken@3407
   209
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   210
 *
slouken@4530
   211
 *  \param window The window about which information is being requested
slouken@7191
   212
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   213
 *              then filled in with information about the given window.
slouken@7191
   214
 *
slouken@7191
   215
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   216
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   217
 *
slouken@3407
   218
 *  You typically use this function like this:
slouken@3407
   219
 *  \code
slouken@4895
   220
 *  SDL_SysWMinfo info;
slouken@3407
   221
 *  SDL_VERSION(&info.version);
slouken@7455
   222
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   223
 *  \endcode
slouken@0
   224
 */
slouken@3685
   225
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   226
                                                     SDL_SysWMinfo * info);
slouken@0
   227
slouken@0
   228
slouken@0
   229
/* Ends C function definitions when using C++ */
slouken@0
   230
#ifdef __cplusplus
slouken@0
   231
}
slouken@0
   232
#endif
slouken@0
   233
#include "close_code.h"
slouken@0
   234
slouken@0
   235
#endif /* _SDL_syswm_h */
slouken@1895
   236
slouken@1895
   237
/* vi: set ts=4 sw=4 expandtab: */