SDL_syswm.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  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. extern "C" {
  33. #endif
  34. /**
  35. * \file SDL_syswm.h
  36. *
  37. * Your application has access to a special type of event ::SDL_SYSWMEVENT,
  38. * which contains window-manager specific information and arrives whenever
  39. * an unhandled window event occurs. This event is ignored by default, but
  40. * you can enable it with SDL_EventState().
  41. */
  42. #ifdef SDL_PROTOTYPES_ONLY
  43. struct SDL_SysWMinfo;
  44. #else
  45. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  46. #define WIN32_LEAN_AND_MEAN
  47. #include <windows.h>
  48. #endif
  49. /* This is the structure for custom window manager events */
  50. #if defined(SDL_VIDEO_DRIVER_X11)
  51. #if defined(__APPLE__) && defined(__MACH__)
  52. /* conflicts with Quickdraw.h */
  53. #define Cursor X11Cursor
  54. #endif
  55. #include <X11/Xlib.h>
  56. #include <X11/Xatom.h>
  57. #if defined(__APPLE__) && defined(__MACH__)
  58. /* matches the re-define above */
  59. #undef Cursor
  60. #endif
  61. #endif /* defined(SDL_VIDEO_DRIVER_X11) */
  62. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  63. #include <directfb.h>
  64. #endif
  65. #if defined(SDL_VIDEO_DRIVER_COCOA)
  66. #ifdef __OBJC__
  67. #include <Cocoa/Cocoa.h>
  68. #else
  69. typedef struct _NSWindow NSWindow;
  70. #endif
  71. #endif
  72. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  73. #ifdef __OBJC__
  74. #include <UIKit/UIKit.h>
  75. #else
  76. typedef struct _UIWindow UIWindow;
  77. #endif
  78. #endif
  79. /**
  80. * These are the various supported windowing subsystems
  81. */
  82. typedef enum
  83. {
  84. SDL_SYSWM_UNKNOWN,
  85. SDL_SYSWM_WINDOWS,
  86. SDL_SYSWM_X11,
  87. SDL_SYSWM_DIRECTFB,
  88. SDL_SYSWM_COCOA,
  89. SDL_SYSWM_UIKIT,
  90. } SDL_SYSWM_TYPE;
  91. /**
  92. * The custom event structure.
  93. */
  94. struct SDL_SysWMmsg
  95. {
  96. SDL_version version;
  97. SDL_SYSWM_TYPE subsystem;
  98. union
  99. {
  100. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  101. struct {
  102. HWND hwnd; /**< The window for the message */
  103. UINT msg; /**< The type of message */
  104. WPARAM wParam; /**< WORD message parameter */
  105. LPARAM lParam; /**< LONG message parameter */
  106. } win;
  107. #endif
  108. #if defined(SDL_VIDEO_DRIVER_X11)
  109. struct {
  110. XEvent event;
  111. } x11;
  112. #endif
  113. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  114. struct {
  115. DFBEvent event;
  116. } dfb;
  117. #endif
  118. #if defined(SDL_VIDEO_DRIVER_COCOA)
  119. struct
  120. {
  121. /* No Cocoa window events yet */
  122. } cocoa;
  123. #endif
  124. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  125. struct
  126. {
  127. /* No UIKit window events yet */
  128. } uikit;
  129. #endif
  130. /* Can't have an empty union */
  131. int dummy;
  132. } msg;
  133. };
  134. /**
  135. * The custom window manager information structure.
  136. *
  137. * When this structure is returned, it holds information about which
  138. * low level system it is using, and will be one of SDL_SYSWM_TYPE.
  139. */
  140. struct SDL_SysWMinfo
  141. {
  142. SDL_version version;
  143. SDL_SYSWM_TYPE subsystem;
  144. union
  145. {
  146. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  147. struct
  148. {
  149. HWND window; /**< The window handle */
  150. } win;
  151. #endif
  152. #if defined(SDL_VIDEO_DRIVER_X11)
  153. struct
  154. {
  155. Display *display; /**< The X11 display */
  156. Window window; /**< The X11 window */
  157. } x11;
  158. #endif
  159. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  160. struct
  161. {
  162. IDirectFB *dfb; /**< The directfb main interface */
  163. IDirectFBWindow *window; /**< The directfb window handle */
  164. IDirectFBSurface *surface; /**< The directfb client surface */
  165. } dfb;
  166. #endif
  167. #if defined(SDL_VIDEO_DRIVER_COCOA)
  168. struct
  169. {
  170. NSWindow *window; /* The Cocoa window */
  171. } cocoa;
  172. #endif
  173. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  174. struct
  175. {
  176. UIWindow *window; /* The UIKit window */
  177. } uikit;
  178. #endif
  179. /* Can't have an empty union */
  180. int dummy;
  181. } info;
  182. };
  183. #endif /* SDL_PROTOTYPES_ONLY */
  184. typedef struct SDL_SysWMinfo SDL_SysWMinfo;
  185. /* Function prototypes */
  186. /**
  187. * \brief This function allows access to driver-dependent window information.
  188. *
  189. * \param window The window about which information is being requested
  190. * \param info This structure must be initialized with the SDL version, and is
  191. * then filled in with information about the given window.
  192. *
  193. * \return SDL_TRUE if the function is implemented and the version member of
  194. * the \c info struct is valid, SDL_FALSE otherwise.
  195. *
  196. * You typically use this function like this:
  197. * \code
  198. * SDL_SysWMinfo info;
  199. * SDL_VERSION(&info.version);
  200. * if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
  201. * \endcode
  202. */
  203. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
  204. SDL_SysWMinfo * info);
  205. /* Ends C function definitions when using C++ */
  206. #ifdef __cplusplus
  207. }
  208. #endif
  209. #include "close_code.h"
  210. #endif /* _SDL_syswm_h */
  211. /* vi: set ts=4 sw=4 expandtab: */