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