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