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