SDL_syswm.h 9.1 KB

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