SDL_syswm.h 8.2 KB

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