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