SDL_syswm.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2014 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. #ifndef WIN32_LEAN_AND_MEAN
  47. #define WIN32_LEAN_AND_MEAN
  48. #endif
  49. #include <windows.h>
  50. #endif
  51. #if defined(SDL_VIDEO_DRIVER_WINRT)
  52. #include <Inspectable.h>
  53. #endif
  54. /* This is the structure for custom window manager events */
  55. #if defined(SDL_VIDEO_DRIVER_X11)
  56. #if defined(__APPLE__) && defined(__MACH__)
  57. /* conflicts with Quickdraw.h */
  58. #define Cursor X11Cursor
  59. #endif
  60. #include <X11/Xlib.h>
  61. #include <X11/Xatom.h>
  62. #if defined(__APPLE__) && defined(__MACH__)
  63. /* matches the re-define above */
  64. #undef Cursor
  65. #endif
  66. #endif /* defined(SDL_VIDEO_DRIVER_X11) */
  67. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  68. #include <directfb.h>
  69. #endif
  70. #if defined(SDL_VIDEO_DRIVER_COCOA)
  71. #ifdef __OBJC__
  72. @class NSWindow;
  73. #else
  74. typedef struct _NSWindow NSWindow;
  75. #endif
  76. #endif
  77. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  78. #ifdef __OBJC__
  79. #include <UIKit/UIKit.h>
  80. #else
  81. typedef struct _UIWindow UIWindow;
  82. typedef struct _UIViewController UIViewController;
  83. #endif
  84. #endif
  85. #if defined(SDL_VIDEO_DRIVER_ANDROID)
  86. typedef struct ANativeWindow ANativeWindow;
  87. typedef void *EGLSurface;
  88. #endif
  89. /**
  90. * These are the various supported windowing subsystems
  91. */
  92. typedef enum
  93. {
  94. SDL_SYSWM_UNKNOWN,
  95. SDL_SYSWM_WINDOWS,
  96. SDL_SYSWM_X11,
  97. SDL_SYSWM_DIRECTFB,
  98. SDL_SYSWM_COCOA,
  99. SDL_SYSWM_UIKIT,
  100. SDL_SYSWM_WAYLAND,
  101. SDL_SYSWM_MIR,
  102. SDL_SYSWM_WINRT,
  103. SDL_SYSWM_ANDROID
  104. } SDL_SYSWM_TYPE;
  105. /**
  106. * The custom event structure.
  107. */
  108. struct SDL_SysWMmsg
  109. {
  110. SDL_version version;
  111. SDL_SYSWM_TYPE subsystem;
  112. union
  113. {
  114. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  115. struct {
  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. } win;
  121. #endif
  122. #if defined(SDL_VIDEO_DRIVER_X11)
  123. struct {
  124. XEvent event;
  125. } x11;
  126. #endif
  127. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  128. struct {
  129. DFBEvent event;
  130. } dfb;
  131. #endif
  132. #if defined(SDL_VIDEO_DRIVER_COCOA)
  133. struct
  134. {
  135. /* Latest version of Xcode clang complains about empty structs in C v. C++:
  136. error: empty struct has size 0 in C, size 1 in C++
  137. */
  138. int dummy;
  139. /* No Cocoa window events yet */
  140. } cocoa;
  141. #endif
  142. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  143. struct
  144. {
  145. /* No UIKit window events yet */
  146. } uikit;
  147. #endif
  148. /* Can't have an empty union */
  149. int dummy;
  150. } msg;
  151. };
  152. /**
  153. * The custom window manager information structure.
  154. *
  155. * When this structure is returned, it holds information about which
  156. * low level system it is using, and will be one of SDL_SYSWM_TYPE.
  157. */
  158. struct SDL_SysWMinfo
  159. {
  160. SDL_version version;
  161. SDL_SYSWM_TYPE subsystem;
  162. union
  163. {
  164. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  165. struct
  166. {
  167. HWND window; /**< The window handle */
  168. } win;
  169. #endif
  170. #if defined(SDL_VIDEO_DRIVER_WINRT)
  171. struct
  172. {
  173. IInspectable * window; /**< The WinRT CoreWindow */
  174. } winrt;
  175. #endif
  176. #if defined(SDL_VIDEO_DRIVER_X11)
  177. struct
  178. {
  179. Display *display; /**< The X11 display */
  180. Window window; /**< The X11 window */
  181. } x11;
  182. #endif
  183. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  184. struct
  185. {
  186. IDirectFB *dfb; /**< The directfb main interface */
  187. IDirectFBWindow *window; /**< The directfb window handle */
  188. IDirectFBSurface *surface; /**< The directfb client surface */
  189. } dfb;
  190. #endif
  191. #if defined(SDL_VIDEO_DRIVER_COCOA)
  192. struct
  193. {
  194. #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
  195. NSWindow __unsafe_unretained *window; /* The Cocoa window */
  196. #else
  197. NSWindow *window; /* The Cocoa window */
  198. #endif
  199. } cocoa;
  200. #endif
  201. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  202. struct
  203. {
  204. #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
  205. UIWindow __unsafe_unretained *window; /* The UIKit window */
  206. #else
  207. UIWindow *window; /* The UIKit window */
  208. #endif
  209. } uikit;
  210. #endif
  211. #if defined(SDL_VIDEO_DRIVER_WAYLAND)
  212. struct
  213. {
  214. struct wl_display *display; /**< Wayland display */
  215. struct wl_surface *surface; /**< Wayland surface */
  216. struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
  217. } wl;
  218. #endif
  219. #if defined(SDL_VIDEO_DRIVER_MIR)
  220. struct
  221. {
  222. struct MirConnection *connection; /**< Mir display server connection */
  223. struct MirSurface *surface; /**< Mir surface */
  224. } mir;
  225. #endif
  226. #if defined(SDL_VIDEO_DRIVER_ANDROID)
  227. struct
  228. {
  229. ANativeWindow *window;
  230. EGLSurface surface;
  231. } android;
  232. #endif
  233. /* Can't have an empty union */
  234. int dummy;
  235. } info;
  236. };
  237. #endif /* SDL_PROTOTYPES_ONLY */
  238. typedef struct SDL_SysWMinfo SDL_SysWMinfo;
  239. /* Function prototypes */
  240. /**
  241. * \brief This function allows access to driver-dependent window information.
  242. *
  243. * \param window The window about which information is being requested
  244. * \param info This structure must be initialized with the SDL version, and is
  245. * then filled in with information about the given window.
  246. *
  247. * \return SDL_TRUE if the function is implemented and the version member of
  248. * the \c info struct is valid, SDL_FALSE otherwise.
  249. *
  250. * You typically use this function like this:
  251. * \code
  252. * SDL_SysWMinfo info;
  253. * SDL_VERSION(&info.version);
  254. * if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
  255. * \endcode
  256. */
  257. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
  258. SDL_SysWMinfo * info);
  259. /* Ends C function definitions when using C++ */
  260. #ifdef __cplusplus
  261. }
  262. #endif
  263. #include "close_code.h"
  264. #endif /* _SDL_syswm_h */
  265. /* vi: set ts=4 sw=4 expandtab: */