include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 31 Dec 2011 09:16:08 -0500
branchSDL-1.2
changeset 6137 4720145f848b
parent 5575 0d5999bb4ba5
child 11979 d684a767e240
permissions -rw-r--r--
Happy New Year!
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@6137
     3
    Copyright (C) 1997-2012 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@4217
    23
/** @file SDL_syswm.h
slouken@4217
    24
 *  Include file for SDL custom system window manager hooks
slouken@4217
    25
 */
slouken@0
    26
slouken@0
    27
#ifndef _SDL_syswm_h
slouken@0
    28
#define _SDL_syswm_h
slouken@0
    29
slouken@1356
    30
#include "SDL_stdinc.h"
slouken@1358
    31
#include "SDL_error.h"
slouken@0
    32
#include "SDL_version.h"
slouken@0
    33
slouken@0
    34
#include "begin_code.h"
slouken@0
    35
/* Set up for C function definitions, even when using C++ */
slouken@0
    36
#ifdef __cplusplus
slouken@0
    37
extern "C" {
slouken@0
    38
#endif
slouken@0
    39
slouken@4217
    40
/** @file SDL_syswm.h
slouken@4217
    41
 *  Your application has access to a special type of event 'SDL_SYSWMEVENT',
slouken@4217
    42
 *  which contains window-manager specific information and arrives whenever
slouken@4217
    43
 *  an unhandled window event occurs.  This event is ignored by default, but
slouken@4217
    44
 *  you can enable it with SDL_EventState()
slouken@4217
    45
 */
slouken@0
    46
#ifdef SDL_PROTOTYPES_ONLY
slouken@0
    47
struct SDL_SysWMinfo;
slouken@0
    48
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@0
    49
#else
slouken@0
    50
slouken@1361
    51
/* This is the structure for custom window manager events */
slouken@1626
    52
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    53
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    54
/* conflicts with Quickdraw.h */
icculus@1133
    55
#define Cursor X11Cursor
icculus@1133
    56
#endif
icculus@1133
    57
slouken@0
    58
#include <X11/Xlib.h>
slouken@0
    59
#include <X11/Xatom.h>
slouken@0
    60
icculus@1133
    61
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    62
/* matches the re-define above */
icculus@1133
    63
#undef Cursor
icculus@1133
    64
#endif
icculus@1133
    65
slouken@4217
    66
/** These are the various supported subsystems under UNIX */
slouken@0
    67
typedef enum {
slouken@0
    68
	SDL_SYSWM_X11
slouken@0
    69
} SDL_SYSWM_TYPE;
slouken@0
    70
slouken@4217
    71
/** The UNIX custom event structure */
slouken@0
    72
struct SDL_SysWMmsg {
slouken@0
    73
	SDL_version version;
slouken@0
    74
	SDL_SYSWM_TYPE subsystem;
slouken@0
    75
	union {
slouken@0
    76
	    XEvent xevent;
slouken@0
    77
	} event;
slouken@0
    78
};
slouken@0
    79
slouken@4217
    80
/** The UNIX custom window manager information structure.
slouken@4217
    81
 *  When this structure is returned, it holds information about which
slouken@4217
    82
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
    83
 */
slouken@911
    84
typedef struct SDL_SysWMinfo {
slouken@0
    85
	SDL_version version;
slouken@0
    86
	SDL_SYSWM_TYPE subsystem;
slouken@0
    87
	union {
slouken@0
    88
	    struct {
slouken@4217
    89
	    	Display *display;	/**< The X11 display */
slouken@4217
    90
	    	Window window;		/**< The X11 display window */
slouken@4217
    91
		/** These locking functions should be called around
slouken@4217
    92
                 *  any X11 functions using the display variable, 
slouken@4217
    93
                 *  but not the gfxdisplay variable.
slouken@4217
    94
                 *  They lock the event thread, so should not be
slouken@4217
    95
		 *  called around event functions or from event filters.
slouken@0
    96
		 */
slouken@4217
    97
                /*@{*/
slouken@0
    98
		void (*lock_func)(void);
slouken@0
    99
		void (*unlock_func)(void);
slouken@4217
   100
                /*@}*/
slouken@0
   101
slouken@4217
   102
		/** @name Introduced in SDL 1.0.2 */
slouken@4217
   103
                /*@{*/
slouken@4217
   104
	    	Window fswindow;	/**< The X11 fullscreen window */
slouken@4217
   105
	    	Window wmwindow;	/**< The X11 managed input window */
slouken@4217
   106
                /*@}*/
slouken@3872
   107
slouken@4217
   108
		/** @name Introduced in SDL 1.2.12 */
slouken@4217
   109
                /*@{*/
slouken@4217
   110
		Display *gfxdisplay;	/**< The X11 display to which rendering is done */
slouken@4217
   111
                /*@}*/
slouken@0
   112
	    } x11;
slouken@0
   113
	} info;
slouken@0
   114
} SDL_SysWMinfo;
slouken@0
   115
slouken@1626
   116
#elif defined(SDL_VIDEO_DRIVER_NANOX)
slouken@30
   117
#include <microwin/nano-X.h>
slouken@30
   118
slouken@4217
   119
/** The generic custom event structure */
slouken@30
   120
struct SDL_SysWMmsg {
slouken@30
   121
	SDL_version version;
slouken@30
   122
	int data;
slouken@30
   123
};
slouken@30
   124
slouken@4217
   125
/** The windows custom window manager information structure */
slouken@911
   126
typedef struct SDL_SysWMinfo {
slouken@30
   127
	SDL_version version ;
slouken@30
   128
	GR_WINDOW_ID window ;	/* The display window */
slouken@30
   129
} SDL_SysWMinfo;
slouken@30
   130
slouken@1760
   131
#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI)
slouken@1433
   132
#define WIN32_LEAN_AND_MEAN
slouken@1433
   133
#include <windows.h>
slouken@0
   134
slouken@4217
   135
/** The windows custom event structure */
slouken@0
   136
struct SDL_SysWMmsg {
slouken@0
   137
	SDL_version version;
slouken@4217
   138
	HWND hwnd;			/**< The window for the message */
slouken@4217
   139
	UINT msg;			/**< The type of message */
slouken@4217
   140
	WPARAM wParam;			/**< WORD message parameter */
slouken@4217
   141
	LPARAM lParam;			/**< LONG message parameter */
slouken@0
   142
};
slouken@0
   143
slouken@4217
   144
/** The windows custom window manager information structure */
slouken@911
   145
typedef struct SDL_SysWMinfo {
slouken@0
   146
	SDL_version version;
slouken@4217
   147
	HWND window;			/**< The Win32 display window */
slouken@4217
   148
	HGLRC hglrc;			/**< The OpenGL context, if any */
slouken@0
   149
} SDL_SysWMinfo;
slouken@0
   150
slouken@1626
   151
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
slouken@630
   152
slouken@4217
   153
/** RISC OS custom event structure */
slouken@630
   154
struct SDL_SysWMmsg {
slouken@630
   155
	SDL_version version;
slouken@4217
   156
	int eventCode;		/**< The window for the message */
slouken@630
   157
	int pollBlock[64];
slouken@630
   158
};
slouken@630
   159
slouken@4217
   160
/** The RISC OS custom window manager information structure */
slouken@911
   161
typedef struct SDL_SysWMinfo {
slouken@630
   162
	SDL_version version;
slouken@4217
   163
	int wimpVersion;    /**< Wimp version running under */
slouken@4217
   164
	int taskHandle;     /**< The RISC OS task handle */
slouken@4217
   165
	int window;		/**< The RISC OS display window */
slouken@630
   166
} SDL_SysWMinfo;
slouken@630
   167
slouken@1626
   168
#elif defined(SDL_VIDEO_DRIVER_PHOTON)
slouken@870
   169
#include <sys/neutrino.h>
slouken@870
   170
#include <Ph.h>
slouken@870
   171
slouken@4217
   172
/** The QNX custom event structure */
slouken@870
   173
struct SDL_SysWMmsg {
slouken@870
   174
	SDL_version version;
slouken@870
   175
	int data;
slouken@870
   176
};
slouken@870
   177
slouken@4217
   178
/** The QNX custom window manager information structure */
slouken@911
   179
typedef struct SDL_SysWMinfo {
slouken@870
   180
	SDL_version version;
slouken@870
   181
	int data;
slouken@870
   182
} SDL_SysWMinfo;
slouken@870
   183
slouken@0
   184
#else
slouken@0
   185
slouken@4217
   186
/** The generic custom event structure */
slouken@0
   187
struct SDL_SysWMmsg {
slouken@0
   188
	SDL_version version;
slouken@0
   189
	int data;
slouken@0
   190
};
slouken@0
   191
slouken@4217
   192
/** The generic custom window manager information structure */
slouken@911
   193
typedef struct SDL_SysWMinfo {
slouken@0
   194
	SDL_version version;
slouken@0
   195
	int data;
slouken@0
   196
} SDL_SysWMinfo;
slouken@0
   197
slouken@1361
   198
#endif /* video driver type */
slouken@0
   199
slouken@0
   200
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   201
slouken@0
   202
/* Function prototypes */
slouken@4217
   203
/**
slouken@0
   204
 * This function gives you custom hooks into the window manager information.
slouken@0
   205
 * It fills the structure pointed to by 'info' with custom information and
slouken@4544
   206
 * returns 0 if the function is not implemented, 1 if the function is 
slouken@4544
   207
 * implemented and no error occurred, and -1 if the version member of
slouken@4544
   208
 * the 'info' structure is not filled in or not supported.
slouken@999
   209
 *
slouken@999
   210
 * You typically use this function like this:
slouken@4217
   211
 * @code
icculus@5575
   212
 * SDL_SysWMinfo info;
slouken@999
   213
 * SDL_VERSION(&info.version);
slouken@999
   214
 * if ( SDL_GetWMInfo(&info) ) { ... }
slouken@4217
   215
 * @endcode
slouken@0
   216
 */
slouken@337
   217
extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);
slouken@0
   218
slouken@0
   219
slouken@0
   220
/* Ends C function definitions when using C++ */
slouken@0
   221
#ifdef __cplusplus
slouken@0
   222
}
slouken@0
   223
#endif
slouken@0
   224
#include "close_code.h"
slouken@0
   225
slouken@0
   226
#endif /* _SDL_syswm_h */