include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 08 Dec 2008 00:25:42 +0000
branchSDL-1.2
changeset 4159 a1b03ba2fcd0
parent 3872 be84332e761e
child 4217 4c4113c2162c
permissions -rw-r--r--
Updated copyright date
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@4159
     3
    Copyright (C) 1997-2009 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@0
    23
/* Include file for SDL custom system window manager hooks */
slouken@0
    24
slouken@0
    25
#ifndef _SDL_syswm_h
slouken@0
    26
#define _SDL_syswm_h
slouken@0
    27
slouken@1356
    28
#include "SDL_stdinc.h"
slouken@1358
    29
#include "SDL_error.h"
slouken@0
    30
#include "SDL_version.h"
slouken@0
    31
slouken@0
    32
#include "begin_code.h"
slouken@0
    33
/* Set up for C function definitions, even when using C++ */
slouken@0
    34
#ifdef __cplusplus
slouken@0
    35
extern "C" {
slouken@0
    36
#endif
slouken@0
    37
slouken@0
    38
/* Your application has access to a special type of event 'SDL_SYSWMEVENT',
slouken@0
    39
   which contains window-manager specific information and arrives whenever
slouken@0
    40
   an unhandled window event occurs.  This event is ignored by default, but
slouken@0
    41
   you can enable it with SDL_EventState()
slouken@0
    42
*/
slouken@0
    43
#ifdef SDL_PROTOTYPES_ONLY
slouken@0
    44
struct SDL_SysWMinfo;
slouken@0
    45
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@0
    46
#else
slouken@0
    47
slouken@1361
    48
/* This is the structure for custom window manager events */
slouken@1626
    49
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    50
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    51
/* conflicts with Quickdraw.h */
icculus@1133
    52
#define Cursor X11Cursor
icculus@1133
    53
#endif
icculus@1133
    54
slouken@0
    55
#include <X11/Xlib.h>
slouken@0
    56
#include <X11/Xatom.h>
slouken@0
    57
icculus@1133
    58
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    59
/* matches the re-define above */
icculus@1133
    60
#undef Cursor
icculus@1133
    61
#endif
icculus@1133
    62
slouken@0
    63
/* These are the various supported subsystems under UNIX */
slouken@0
    64
typedef enum {
slouken@0
    65
	SDL_SYSWM_X11
slouken@0
    66
} SDL_SYSWM_TYPE;
slouken@0
    67
slouken@0
    68
/* The UNIX custom event structure */
slouken@0
    69
struct SDL_SysWMmsg {
slouken@0
    70
	SDL_version version;
slouken@0
    71
	SDL_SYSWM_TYPE subsystem;
slouken@0
    72
	union {
slouken@0
    73
	    XEvent xevent;
slouken@0
    74
	} event;
slouken@0
    75
};
slouken@0
    76
slouken@0
    77
/* The UNIX custom window manager information structure.
slouken@0
    78
   When this structure is returned, it holds information about which
slouken@0
    79
   low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
    80
 */
slouken@911
    81
typedef struct SDL_SysWMinfo {
slouken@0
    82
	SDL_version version;
slouken@0
    83
	SDL_SYSWM_TYPE subsystem;
slouken@0
    84
	union {
slouken@0
    85
	    struct {
slouken@0
    86
	    	Display *display;	/* The X11 display */
slouken@0
    87
	    	Window window;		/* The X11 display window */
slouken@0
    88
		/* These locking functions should be called around
slouken@3872
    89
                   any X11 functions using the display variable, 
slouken@3872
    90
                   but not the gfxdisplay variable.
slouken@0
    91
                   They lock the event thread, so should not be
slouken@0
    92
		   called around event functions or from event filters.
slouken@0
    93
		 */
slouken@0
    94
		void (*lock_func)(void);
slouken@0
    95
		void (*unlock_func)(void);
slouken@0
    96
slouken@0
    97
		/* Introduced in SDL 1.0.2 */
slouken@0
    98
	    	Window fswindow;	/* The X11 fullscreen window */
slouken@0
    99
	    	Window wmwindow;	/* The X11 managed input window */
slouken@3872
   100
slouken@3872
   101
		/* Introduced in SDL 1.2.12 */
slouken@3872
   102
		Display *gfxdisplay;	/* The X11 display to which rendering is done */
slouken@0
   103
	    } x11;
slouken@0
   104
	} info;
slouken@0
   105
} SDL_SysWMinfo;
slouken@0
   106
slouken@1626
   107
#elif defined(SDL_VIDEO_DRIVER_NANOX)
slouken@30
   108
#include <microwin/nano-X.h>
slouken@30
   109
slouken@30
   110
/* The generic custom event structure */
slouken@30
   111
struct SDL_SysWMmsg {
slouken@30
   112
	SDL_version version;
slouken@30
   113
	int data;
slouken@30
   114
};
slouken@30
   115
slouken@30
   116
/* The windows custom window manager information structure */
slouken@911
   117
typedef struct SDL_SysWMinfo {
slouken@30
   118
	SDL_version version ;
slouken@30
   119
	GR_WINDOW_ID window ;	/* The display window */
slouken@30
   120
} SDL_SysWMinfo;
slouken@30
   121
slouken@1760
   122
#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI)
slouken@1433
   123
#define WIN32_LEAN_AND_MEAN
slouken@1433
   124
#include <windows.h>
slouken@0
   125
slouken@0
   126
/* The windows custom event structure */
slouken@0
   127
struct SDL_SysWMmsg {
slouken@0
   128
	SDL_version version;
slouken@0
   129
	HWND hwnd;			/* The window for the message */
slouken@0
   130
	UINT msg;			/* The type of message */
slouken@0
   131
	WPARAM wParam;			/* WORD message parameter */
slouken@0
   132
	LPARAM lParam;			/* LONG message parameter */
slouken@0
   133
};
slouken@0
   134
slouken@0
   135
/* The windows custom window manager information structure */
slouken@911
   136
typedef struct SDL_SysWMinfo {
slouken@0
   137
	SDL_version version;
slouken@0
   138
	HWND window;			/* The Win32 display window */
slouken@438
   139
	HGLRC hglrc;			/* The OpenGL context, if any */
slouken@0
   140
} SDL_SysWMinfo;
slouken@0
   141
slouken@1626
   142
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
slouken@630
   143
slouken@630
   144
/* RISC OS custom event structure */
slouken@630
   145
struct SDL_SysWMmsg {
slouken@630
   146
	SDL_version version;
slouken@630
   147
	int eventCode;		/* The window for the message */
slouken@630
   148
	int pollBlock[64];
slouken@630
   149
};
slouken@630
   150
slouken@1035
   151
/* The RISC OS custom window manager information structure */
slouken@911
   152
typedef struct SDL_SysWMinfo {
slouken@630
   153
	SDL_version version;
slouken@630
   154
	int wimpVersion;    /* Wimp version running under */
slouken@1035
   155
	int taskHandle;     /* The RISC OS task handle */
slouken@1035
   156
	int window;		/* The RISC OS display window */
slouken@630
   157
} SDL_SysWMinfo;
slouken@630
   158
slouken@1626
   159
#elif defined(SDL_VIDEO_DRIVER_PHOTON)
slouken@870
   160
#include <sys/neutrino.h>
slouken@870
   161
#include <Ph.h>
slouken@870
   162
slouken@870
   163
/* The QNX custom event structure */
slouken@870
   164
struct SDL_SysWMmsg {
slouken@870
   165
	SDL_version version;
slouken@870
   166
	int data;
slouken@870
   167
};
slouken@870
   168
slouken@870
   169
/* The QNX custom window manager information structure */
slouken@911
   170
typedef struct SDL_SysWMinfo {
slouken@870
   171
	SDL_version version;
slouken@870
   172
	int data;
slouken@870
   173
} SDL_SysWMinfo;
slouken@870
   174
slouken@0
   175
#else
slouken@0
   176
slouken@0
   177
/* The generic custom event structure */
slouken@0
   178
struct SDL_SysWMmsg {
slouken@0
   179
	SDL_version version;
slouken@0
   180
	int data;
slouken@0
   181
};
slouken@0
   182
slouken@0
   183
/* The generic custom window manager information structure */
slouken@911
   184
typedef struct SDL_SysWMinfo {
slouken@0
   185
	SDL_version version;
slouken@0
   186
	int data;
slouken@0
   187
} SDL_SysWMinfo;
slouken@0
   188
slouken@1361
   189
#endif /* video driver type */
slouken@0
   190
slouken@0
   191
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   192
slouken@0
   193
/* Function prototypes */
slouken@0
   194
/*
slouken@0
   195
 * This function gives you custom hooks into the window manager information.
slouken@0
   196
 * It fills the structure pointed to by 'info' with custom information and
slouken@0
   197
 * returns 1 if the function is implemented.  If it's not implemented, or
slouken@0
   198
 * the version member of the 'info' structure is invalid, it returns 0. 
slouken@999
   199
 *
slouken@999
   200
 * You typically use this function like this:
slouken@999
   201
 * SDL_SysWMInfo info;
slouken@999
   202
 * SDL_VERSION(&info.version);
slouken@999
   203
 * if ( SDL_GetWMInfo(&info) ) { ... }
slouken@0
   204
 */
slouken@337
   205
extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);
slouken@0
   206
slouken@0
   207
slouken@0
   208
/* Ends C function definitions when using C++ */
slouken@0
   209
#ifdef __cplusplus
slouken@0
   210
}
slouken@0
   211
#endif
slouken@0
   212
#include "close_code.h"
slouken@0
   213
slouken@0
   214
#endif /* _SDL_syswm_h */