SDL_syswm.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 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. /**
  30. * \brief SDL_syswm.h
  31. *
  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. struct SDL_SysWMinfo;
  38. #if !defined(SDL_PROTOTYPES_ONLY)
  39. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  40. #ifndef WIN32_LEAN_AND_MEAN
  41. #define WIN32_LEAN_AND_MEAN
  42. #endif
  43. #ifndef NOMINMAX /* don't define min() and max(). */
  44. #define NOMINMAX
  45. #endif
  46. #include <windows.h>
  47. #endif
  48. #if defined(SDL_VIDEO_DRIVER_WINRT)
  49. #include <Inspectable.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.h>
  66. #endif
  67. #if defined(SDL_VIDEO_DRIVER_COCOA)
  68. #ifdef __OBJC__
  69. @class NSWindow;
  70. #else
  71. typedef struct _NSWindow NSWindow;
  72. #endif
  73. #endif
  74. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  75. #ifdef __OBJC__
  76. #include <UIKit/UIKit.h>
  77. #else
  78. typedef struct _UIWindow UIWindow;
  79. typedef struct _UIViewController UIViewController;
  80. #endif
  81. typedef Uint32 GLuint;
  82. #endif
  83. #if defined(SDL_VIDEO_DRIVER_ANDROID)
  84. typedef struct ANativeWindow ANativeWindow;
  85. typedef void *EGLSurface;
  86. #endif
  87. #if defined(SDL_VIDEO_DRIVER_VIVANTE)
  88. #include "SDL_egl.h"
  89. #endif
  90. #if defined(SDL_VIDEO_DRIVER_OS2)
  91. #define INCL_WIN
  92. #include <os2.h>
  93. #endif
  94. #endif /* SDL_PROTOTYPES_ONLY */
  95. #include "begin_code.h"
  96. /* Set up for C function definitions, even when using C++ */
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. #if !defined(SDL_PROTOTYPES_ONLY)
  101. /**
  102. * These are the various supported windowing subsystems
  103. */
  104. typedef enum
  105. {
  106. SDL_SYSWM_UNKNOWN,
  107. SDL_SYSWM_WINDOWS,
  108. SDL_SYSWM_X11,
  109. SDL_SYSWM_DIRECTFB,
  110. SDL_SYSWM_COCOA,
  111. SDL_SYSWM_UIKIT,
  112. SDL_SYSWM_WAYLAND,
  113. SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
  114. SDL_SYSWM_WINRT,
  115. SDL_SYSWM_ANDROID,
  116. SDL_SYSWM_VIVANTE,
  117. SDL_SYSWM_OS2,
  118. SDL_SYSWM_HAIKU
  119. } SDL_SYSWM_TYPE;
  120. /**
  121. * The custom event structure.
  122. */
  123. struct SDL_SysWMmsg
  124. {
  125. SDL_version version;
  126. SDL_SYSWM_TYPE subsystem;
  127. union
  128. {
  129. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  130. struct {
  131. HWND hwnd; /**< The window for the message */
  132. UINT msg; /**< The type of message */
  133. WPARAM wParam; /**< WORD message parameter */
  134. LPARAM lParam; /**< LONG message parameter */
  135. } win;
  136. #endif
  137. #if defined(SDL_VIDEO_DRIVER_X11)
  138. struct {
  139. XEvent event;
  140. } x11;
  141. #endif
  142. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  143. struct {
  144. DFBEvent event;
  145. } dfb;
  146. #endif
  147. #if defined(SDL_VIDEO_DRIVER_COCOA)
  148. struct
  149. {
  150. /* Latest version of Xcode clang complains about empty structs in C v. C++:
  151. error: empty struct has size 0 in C, size 1 in C++
  152. */
  153. int dummy;
  154. /* No Cocoa window events yet */
  155. } cocoa;
  156. #endif
  157. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  158. struct
  159. {
  160. int dummy;
  161. /* No UIKit window events yet */
  162. } uikit;
  163. #endif
  164. #if defined(SDL_VIDEO_DRIVER_VIVANTE)
  165. struct
  166. {
  167. int dummy;
  168. /* No Vivante window events yet */
  169. } vivante;
  170. #endif
  171. #if defined(SDL_VIDEO_DRIVER_OS2)
  172. struct
  173. {
  174. BOOL fFrame; /**< TRUE if hwnd is a frame window */
  175. HWND hwnd; /**< The window receiving the message */
  176. ULONG msg; /**< The message identifier */
  177. MPARAM mp1; /**< The first first message parameter */
  178. MPARAM mp2; /**< The second first message parameter */
  179. } os2;
  180. #endif
  181. /* Can't have an empty union */
  182. int dummy;
  183. } msg;
  184. };
  185. /**
  186. * The custom window manager information structure.
  187. *
  188. * When this structure is returned, it holds information about which
  189. * low level system it is using, and will be one of SDL_SYSWM_TYPE.
  190. */
  191. struct SDL_SysWMinfo
  192. {
  193. SDL_version version;
  194. SDL_SYSWM_TYPE subsystem;
  195. union
  196. {
  197. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  198. struct
  199. {
  200. HWND window; /**< The window handle */
  201. HDC hdc; /**< The window device context */
  202. HINSTANCE hinstance; /**< The instance handle */
  203. } win;
  204. #endif
  205. #if defined(SDL_VIDEO_DRIVER_WINRT)
  206. struct
  207. {
  208. IInspectable * window; /**< The WinRT CoreWindow */
  209. } winrt;
  210. #endif
  211. #if defined(SDL_VIDEO_DRIVER_X11)
  212. struct
  213. {
  214. Display *display; /**< The X11 display */
  215. Window window; /**< The X11 window */
  216. } x11;
  217. #endif
  218. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  219. struct
  220. {
  221. IDirectFB *dfb; /**< The directfb main interface */
  222. IDirectFBWindow *window; /**< The directfb window handle */
  223. IDirectFBSurface *surface; /**< The directfb client surface */
  224. } dfb;
  225. #endif
  226. #if defined(SDL_VIDEO_DRIVER_COCOA)
  227. struct
  228. {
  229. #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
  230. NSWindow __unsafe_unretained *window; /**< The Cocoa window */
  231. #else
  232. NSWindow *window; /**< The Cocoa window */
  233. #endif
  234. } cocoa;
  235. #endif
  236. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  237. struct
  238. {
  239. #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
  240. UIWindow __unsafe_unretained *window; /**< The UIKit window */
  241. #else
  242. UIWindow *window; /**< The UIKit window */
  243. #endif
  244. GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
  245. GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
  246. GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
  247. } uikit;
  248. #endif
  249. #if defined(SDL_VIDEO_DRIVER_WAYLAND)
  250. struct
  251. {
  252. struct wl_display *display; /**< Wayland display */
  253. struct wl_surface *surface; /**< Wayland surface */
  254. struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
  255. } wl;
  256. #endif
  257. #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
  258. struct
  259. {
  260. void *connection; /**< Mir display server connection */
  261. void *surface; /**< Mir surface */
  262. } mir;
  263. #endif
  264. #if defined(SDL_VIDEO_DRIVER_ANDROID)
  265. struct
  266. {
  267. ANativeWindow *window;
  268. EGLSurface surface;
  269. } android;
  270. #endif
  271. #if defined(SDL_VIDEO_DRIVER_OS2)
  272. struct
  273. {
  274. HWND hwnd; /**< The window handle */
  275. HWND hwndFrame; /**< The frame window handle */
  276. } os2;
  277. #endif
  278. #if defined(SDL_VIDEO_DRIVER_VIVANTE)
  279. struct
  280. {
  281. EGLNativeDisplayType display;
  282. EGLNativeWindowType window;
  283. } vivante;
  284. #endif
  285. /* Make sure this union is always 64 bytes (8 64-bit pointers). */
  286. /* Be careful not to overflow this if you add a new target! */
  287. Uint8 dummy[64];
  288. } info;
  289. };
  290. #endif /* SDL_PROTOTYPES_ONLY */
  291. typedef struct SDL_SysWMinfo SDL_SysWMinfo;
  292. /* Function prototypes */
  293. /**
  294. * \brief This function allows access to driver-dependent window information.
  295. *
  296. * \param window The window about which information is being requested
  297. * \param info This structure must be initialized with the SDL version, and is
  298. * then filled in with information about the given window.
  299. *
  300. * \return SDL_TRUE if the function is implemented and the version member of
  301. * the \c info struct is valid, SDL_FALSE otherwise.
  302. *
  303. * You typically use this function like this:
  304. * \code
  305. * SDL_SysWMinfo info;
  306. * SDL_VERSION(&info.version);
  307. * if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
  308. * \endcode
  309. */
  310. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
  311. SDL_SysWMinfo * info);
  312. /* Ends C function definitions when using C++ */
  313. #ifdef __cplusplus
  314. }
  315. #endif
  316. #include "close_code.h"
  317. #endif /* SDL_syswm_h_ */
  318. /* vi: set ts=4 sw=4 expandtab: */