SDL_syswm.h 6.2 KB

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