include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 16 Feb 2006 10:11:48 +0000
changeset 1361 19418e4422cb
parent 1358 c71e05b4dc2e
child 1433 bb6839704ed6
permissions -rw-r--r--
New configure-based build system. Still work in progress, but much improved
     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 /* This is the structure for custom window manager events */
    49 #if SDL_VIDEO_DRIVER_X11
    50 #if defined(__APPLE__) && defined(__MACH__)
    51 // conflicts with Quickdraw.h
    52 #define Cursor X11Cursor
    53 #endif
    54 
    55 #include <X11/Xlib.h>
    56 #include <X11/Xatom.h>
    57 
    58 #if defined(__APPLE__) && defined(__MACH__)
    59 // matches the re-define above
    60 #undef Cursor
    61 #endif
    62 
    63 /* These are the various supported subsystems under UNIX */
    64 typedef enum {
    65 	SDL_SYSWM_X11
    66 } SDL_SYSWM_TYPE;
    67 
    68 /* The UNIX custom event structure */
    69 struct SDL_SysWMmsg {
    70 	SDL_version version;
    71 	SDL_SYSWM_TYPE subsystem;
    72 	union {
    73 	    XEvent xevent;
    74 	} event;
    75 };
    76 
    77 /* The UNIX custom window manager information structure.
    78    When this structure is returned, it holds information about which
    79    low level system it is using, and will be one of SDL_SYSWM_TYPE.
    80  */
    81 typedef struct SDL_SysWMinfo {
    82 	SDL_version version;
    83 	SDL_SYSWM_TYPE subsystem;
    84 	union {
    85 	    struct {
    86 	    	Display *display;	/* The X11 display */
    87 	    	Window window;		/* The X11 display window */
    88 		/* These locking functions should be called around
    89                    any X11 functions using the display variable.
    90                    They lock the event thread, so should not be
    91 		   called around event functions or from event filters.
    92 		 */
    93 		void (*lock_func)(void);
    94 		void (*unlock_func)(void);
    95 
    96 		/* Introduced in SDL 1.0.2 */
    97 	    	Window fswindow;	/* The X11 fullscreen window */
    98 	    	Window wmwindow;	/* The X11 managed input window */
    99 	    } x11;
   100 	} info;
   101 } SDL_SysWMinfo;
   102 
   103 #elif SDL_VIDEO_DRIVER_NANOX
   104 #include <microwin/nano-X.h>
   105 
   106 /* The generic custom event structure */
   107 struct SDL_SysWMmsg {
   108 	SDL_version version;
   109 	int data;
   110 };
   111 
   112 /* The windows custom window manager information structure */
   113 typedef struct SDL_SysWMinfo {
   114 	SDL_version version ;
   115 	GR_WINDOW_ID window ;	/* The display window */
   116 } SDL_SysWMinfo;
   117 
   118 #elif SDL_VIDEO_DRIVER_WINDIB || SDL_VIDEO_DRIVER_DDRAW
   119 #include "SDL_windows.h"
   120 
   121 /* The windows custom event structure */
   122 struct SDL_SysWMmsg {
   123 	SDL_version version;
   124 	HWND hwnd;			/* The window for the message */
   125 	UINT msg;			/* The type of message */
   126 	WPARAM wParam;			/* WORD message parameter */
   127 	LPARAM lParam;			/* LONG message parameter */
   128 };
   129 
   130 /* The windows custom window manager information structure */
   131 typedef struct SDL_SysWMinfo {
   132 	SDL_version version;
   133 	HWND window;			/* The Win32 display window */
   134 	HGLRC hglrc;			/* The OpenGL context, if any */
   135 } SDL_SysWMinfo;
   136 
   137 #elif SDL_VIDEO_DRIVER_RISCOS
   138 
   139 /* RISC OS custom event structure */
   140 struct SDL_SysWMmsg {
   141 	SDL_version version;
   142 	int eventCode;		/* The window for the message */
   143 	int pollBlock[64];
   144 };
   145 
   146 /* The RISC OS custom window manager information structure */
   147 typedef struct SDL_SysWMinfo {
   148 	SDL_version version;
   149 	int wimpVersion;    /* Wimp version running under */
   150 	int taskHandle;     /* The RISC OS task handle */
   151 	int window;		/* The RISC OS display window */
   152 } SDL_SysWMinfo;
   153 
   154 #elif SDL_VIDEO_DRIVER_PHOTON
   155 #include <sys/neutrino.h>
   156 #include <Ph.h>
   157 
   158 /* The QNX custom event structure */
   159 struct SDL_SysWMmsg {
   160 	SDL_version version;
   161 	int data;
   162 };
   163 
   164 /* The QNX custom window manager information structure */
   165 typedef struct SDL_SysWMinfo {
   166 	SDL_version version;
   167 	int data;
   168 } SDL_SysWMinfo;
   169 
   170 #else
   171 
   172 /* The generic custom event structure */
   173 struct SDL_SysWMmsg {
   174 	SDL_version version;
   175 	int data;
   176 };
   177 
   178 /* The generic custom window manager information structure */
   179 typedef struct SDL_SysWMinfo {
   180 	SDL_version version;
   181 	int data;
   182 } SDL_SysWMinfo;
   183 
   184 #endif /* video driver type */
   185 
   186 #endif /* SDL_PROTOTYPES_ONLY */
   187 
   188 /* Function prototypes */
   189 /*
   190  * This function gives you custom hooks into the window manager information.
   191  * It fills the structure pointed to by 'info' with custom information and
   192  * returns 1 if the function is implemented.  If it's not implemented, or
   193  * the version member of the 'info' structure is invalid, it returns 0. 
   194  *
   195  * You typically use this function like this:
   196  * SDL_SysWMInfo info;
   197  * SDL_VERSION(&info.version);
   198  * if ( SDL_GetWMInfo(&info) ) { ... }
   199  */
   200 extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);
   201 
   202 
   203 /* Ends C function definitions when using C++ */
   204 #ifdef __cplusplus
   205 }
   206 #endif
   207 #include "close_code.h"
   208 
   209 #endif /* _SDL_syswm_h */