SDL_syswm.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2010 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. [email protected]
  17. */
  18. /**
  19. * \file SDL_syswm.h
  20. *
  21. * Include file for SDL custom system window manager hooks.
  22. */
  23. #ifndef _SDL_syswm_h
  24. #define _SDL_syswm_h
  25. #include "SDL_stdinc.h"
  26. #include "SDL_error.h"
  27. #include "SDL_video.h"
  28. #include "SDL_version.h"
  29. #include "begin_code.h"
  30. /* Set up for C function definitions, even when using C++ */
  31. #ifdef __cplusplus
  32. /* *INDENT-OFF* */
  33. extern "C" {
  34. /* *INDENT-ON* */
  35. #endif
  36. /**
  37. * \file SDL_syswm.h
  38. *
  39. * Your application has access to a special type of event ::SDL_SYSWMEVENT,
  40. * which contains window-manager specific information and arrives whenever
  41. * an unhandled window event occurs. This event is ignored by default, but
  42. * you can enable it with SDL_EventState().
  43. */
  44. #ifdef SDL_PROTOTYPES_ONLY
  45. struct SDL_SysWMinfo;
  46. #else
  47. #if defined(SDL_VIDEO_DRIVER_WIN32)
  48. #define WIN32_LEAN_AND_MEAN
  49. #include <windows.h>
  50. #endif
  51. /* This is the structure for custom window manager events */
  52. #if defined(SDL_VIDEO_DRIVER_X11)
  53. #if defined(__APPLE__) && defined(__MACH__)
  54. /* conflicts with Quickdraw.h */
  55. #define Cursor X11Cursor
  56. #endif
  57. #include <X11/Xlib.h>
  58. #include <X11/Xatom.h>
  59. #if defined(__APPLE__) && defined(__MACH__)
  60. /* matches the re-define above */
  61. #undef Cursor
  62. #endif
  63. #endif /* defined(SDL_VIDEO_DRIVER_X11) */
  64. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  65. #include <directfb/directfb.h>
  66. #endif
  67. #if defined(SDL_VIDEO_DRIVER_COCOA)
  68. #ifdef __OBJC__
  69. #include <Cocoa/Cocoa.h>
  70. #else
  71. typedef struct _NSWindow NSWindow;
  72. #endif
  73. #endif
  74. /**
  75. * These are the various supported windowing subsystems
  76. */
  77. typedef enum
  78. {
  79. SDL_SYSWM_UNKNOWN,
  80. SDL_SYSWM_WINDOWS,
  81. SDL_SYSWM_X11,
  82. SDL_SYSWM_DIRECTFB,
  83. SDL_SYSWM_COCOA,
  84. } SDL_SYSWM_TYPE;
  85. /**
  86. * The custom event structure.
  87. */
  88. struct SDL_SysWMmsg
  89. {
  90. SDL_version version;
  91. SDL_SYSWM_TYPE subsystem;
  92. union
  93. {
  94. #if defined(SDL_VIDEO_DRIVER_WIN32)
  95. struct {
  96. HWND hwnd; /**< The window for the message */
  97. UINT msg; /**< The type of message */
  98. WPARAM wParam; /**< WORD message parameter */
  99. LPARAM lParam; /**< LONG message parameter */
  100. } win;
  101. #endif
  102. #if defined(SDL_VIDEO_DRIVER_X11)
  103. struct {
  104. XEvent event;
  105. } x11;
  106. #endif
  107. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  108. struct {
  109. DFBEvent event;
  110. } dfb;
  111. #endif
  112. #if defined(SDL_VIDEO_DRIVER_COCOA)
  113. struct
  114. {
  115. /* No Cocoa window events yet */
  116. } cocoa;
  117. #endif
  118. } /*msg*/;
  119. };
  120. /**
  121. * The custom window manager information structure.
  122. *
  123. * When this structure is returned, it holds information about which
  124. * low level system it is using, and will be one of SDL_SYSWM_TYPE.
  125. */
  126. struct SDL_SysWMinfo
  127. {
  128. SDL_version version;
  129. SDL_SYSWM_TYPE subsystem;
  130. union
  131. {
  132. #if defined(SDL_VIDEO_DRIVER_WIN32)
  133. struct
  134. {
  135. HWND window; /**< The window handle */
  136. } win;
  137. #endif
  138. #if defined(SDL_VIDEO_DRIVER_X11)
  139. struct
  140. {
  141. Display *display; /**< The X11 display */
  142. Window window; /**< The X11 window */
  143. } x11;
  144. #endif
  145. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  146. struct
  147. {
  148. IDirectFB *dfb; /**< The directfb main interface */
  149. IDirectFBWindow *window; /**< The directfb window handle */
  150. IDirectFBSurface *surface; /**< The directfb client surface */
  151. } dfb;
  152. #endif
  153. #if defined(SDL_VIDEO_DRIVER_COCOA)
  154. struct
  155. {
  156. NSWindow *window; /* The Cocoa window */
  157. } cocoa;
  158. #endif
  159. } /*info*/;
  160. };
  161. #endif /* SDL_PROTOTYPES_ONLY */
  162. typedef struct SDL_SysWMinfo SDL_SysWMinfo;
  163. /* Function prototypes */
  164. /**
  165. * \brief This function allows access to driver-dependent window information.
  166. *
  167. * \param window The window about which information is being requested
  168. * \param info This structure must be initialized with the SDL version, and is
  169. * then filled in with information about the given window.
  170. *
  171. * \return SDL_TRUE if the function is implemented and the version member of
  172. * the \c info struct is valid, SDL_FALSE otherwise.
  173. *
  174. * You typically use this function like this:
  175. * \code
  176. * SDL_SysWMinfo info;
  177. * SDL_VERSION(&info.version);
  178. * if ( SDL_GetWindowWMInfo(&info) ) { ... }
  179. * \endcode
  180. */
  181. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
  182. SDL_SysWMinfo * info);
  183. /* Ends C function definitions when using C++ */
  184. #ifdef __cplusplus
  185. /* *INDENT-OFF* */
  186. }
  187. /* *INDENT-ON* */
  188. #endif
  189. #include "close_code.h"
  190. #endif /* _SDL_syswm_h */
  191. /* vi: set ts=4 sw=4 expandtab: */