🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 lines
11 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 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_VULKAN) || defined(SDL_VIDEO_METAL)
  84. #define SDL_METALVIEW_TAG 255
  85. #endif
  86. #if defined(SDL_VIDEO_DRIVER_ANDROID)
  87. typedef struct ANativeWindow ANativeWindow;
  88. typedef void *EGLSurface;
  89. #endif
  90. #if defined(SDL_VIDEO_DRIVER_VIVANTE)
  91. #include "SDL_egl.h"
  92. #endif
  93. #if defined(SDL_VIDEO_DRIVER_OS2)
  94. #define INCL_WIN
  95. #include <os2.h>
  96. #endif
  97. #endif /* SDL_PROTOTYPES_ONLY */
  98. #if defined(SDL_VIDEO_DRIVER_KMSDRM)
  99. struct gbm_device;
  100. #endif
  101. #include "begin_code.h"
  102. /* Set up for C function definitions, even when using C++ */
  103. #ifdef __cplusplus
  104. extern "C" {
  105. #endif
  106. #if !defined(SDL_PROTOTYPES_ONLY)
  107. /**
  108. * These are the various supported windowing subsystems
  109. */
  110. typedef enum
  111. {
  112. SDL_SYSWM_UNKNOWN,
  113. SDL_SYSWM_WINDOWS,
  114. SDL_SYSWM_X11,
  115. SDL_SYSWM_DIRECTFB,
  116. SDL_SYSWM_COCOA,
  117. SDL_SYSWM_UIKIT,
  118. SDL_SYSWM_WAYLAND,
  119. SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
  120. SDL_SYSWM_WINRT,
  121. SDL_SYSWM_ANDROID,
  122. SDL_SYSWM_VIVANTE,
  123. SDL_SYSWM_OS2,
  124. SDL_SYSWM_HAIKU,
  125. SDL_SYSWM_KMSDRM,
  126. SDL_SYSWM_RISCOS
  127. } SDL_SYSWM_TYPE;
  128. /**
  129. * The custom event structure.
  130. */
  131. struct SDL_SysWMmsg
  132. {
  133. SDL_version version;
  134. SDL_SYSWM_TYPE subsystem;
  135. union
  136. {
  137. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  138. struct {
  139. HWND hwnd; /**< The window for the message */
  140. UINT msg; /**< The type of message */
  141. WPARAM wParam; /**< WORD message parameter */
  142. LPARAM lParam; /**< LONG message parameter */
  143. } win;
  144. #endif
  145. #if defined(SDL_VIDEO_DRIVER_X11)
  146. struct {
  147. XEvent event;
  148. } x11;
  149. #endif
  150. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  151. struct {
  152. DFBEvent event;
  153. } dfb;
  154. #endif
  155. #if defined(SDL_VIDEO_DRIVER_COCOA)
  156. struct
  157. {
  158. /* Latest version of Xcode clang complains about empty structs in C v. C++:
  159. error: empty struct has size 0 in C, size 1 in C++
  160. */
  161. int dummy;
  162. /* No Cocoa window events yet */
  163. } cocoa;
  164. #endif
  165. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  166. struct
  167. {
  168. int dummy;
  169. /* No UIKit window events yet */
  170. } uikit;
  171. #endif
  172. #if defined(SDL_VIDEO_DRIVER_VIVANTE)
  173. struct
  174. {
  175. int dummy;
  176. /* No Vivante window events yet */
  177. } vivante;
  178. #endif
  179. #if defined(SDL_VIDEO_DRIVER_OS2)
  180. struct
  181. {
  182. BOOL fFrame; /**< TRUE if hwnd is a frame window */
  183. HWND hwnd; /**< The window receiving the message */
  184. ULONG msg; /**< The message identifier */
  185. MPARAM mp1; /**< The first first message parameter */
  186. MPARAM mp2; /**< The second first message parameter */
  187. } os2;
  188. #endif
  189. /* Can't have an empty union */
  190. int dummy;
  191. } msg;
  192. };
  193. /**
  194. * The custom window manager information structure.
  195. *
  196. * When this structure is returned, it holds information about which
  197. * low level system it is using, and will be one of SDL_SYSWM_TYPE.
  198. */
  199. struct SDL_SysWMinfo
  200. {
  201. SDL_version version;
  202. SDL_SYSWM_TYPE subsystem;
  203. union
  204. {
  205. #if defined(SDL_VIDEO_DRIVER_WINDOWS)
  206. struct
  207. {
  208. HWND window; /**< The window handle */
  209. HDC hdc; /**< The window device context */
  210. HINSTANCE hinstance; /**< The instance handle */
  211. } win;
  212. #endif
  213. #if defined(SDL_VIDEO_DRIVER_WINRT)
  214. struct
  215. {
  216. IInspectable * window; /**< The WinRT CoreWindow */
  217. } winrt;
  218. #endif
  219. #if defined(SDL_VIDEO_DRIVER_X11)
  220. struct
  221. {
  222. Display *display; /**< The X11 display */
  223. Window window; /**< The X11 window */
  224. } x11;
  225. #endif
  226. #if defined(SDL_VIDEO_DRIVER_DIRECTFB)
  227. struct
  228. {
  229. IDirectFB *dfb; /**< The directfb main interface */
  230. IDirectFBWindow *window; /**< The directfb window handle */
  231. IDirectFBSurface *surface; /**< The directfb client surface */
  232. } dfb;
  233. #endif
  234. #if defined(SDL_VIDEO_DRIVER_COCOA)
  235. struct
  236. {
  237. #if defined(__OBJC__) && defined(__has_feature)
  238. #if __has_feature(objc_arc)
  239. NSWindow __unsafe_unretained *window; /**< The Cocoa window */
  240. #else
  241. NSWindow *window; /**< The Cocoa window */
  242. #endif
  243. #else
  244. NSWindow *window; /**< The Cocoa window */
  245. #endif
  246. } cocoa;
  247. #endif
  248. #if defined(SDL_VIDEO_DRIVER_UIKIT)
  249. struct
  250. {
  251. #if defined(__OBJC__) && defined(__has_feature)
  252. #if __has_feature(objc_arc)
  253. UIWindow __unsafe_unretained *window; /**< The UIKit window */
  254. #else
  255. UIWindow *window; /**< The UIKit window */
  256. #endif
  257. #else
  258. UIWindow *window; /**< The UIKit window */
  259. #endif
  260. GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
  261. GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
  262. GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
  263. } uikit;
  264. #endif
  265. #if defined(SDL_VIDEO_DRIVER_WAYLAND)
  266. struct
  267. {
  268. struct wl_display *display; /**< Wayland display */
  269. struct wl_surface *surface; /**< Wayland surface */
  270. void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */
  271. struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */
  272. struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */
  273. struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */
  274. struct xdg_popup *xdg_popup; /**< Wayland xdg popup role */
  275. struct xdg_positioner *xdg_positioner; /**< Wayland xdg positioner, for popup */
  276. } wl;
  277. #endif
  278. #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */
  279. struct
  280. {
  281. void *connection; /**< Mir display server connection */
  282. void *surface; /**< Mir surface */
  283. } mir;
  284. #endif
  285. #if defined(SDL_VIDEO_DRIVER_ANDROID)
  286. struct
  287. {
  288. ANativeWindow *window;
  289. EGLSurface surface;
  290. } android;
  291. #endif
  292. #if defined(SDL_VIDEO_DRIVER_OS2)
  293. struct
  294. {
  295. HWND hwnd; /**< The window handle */
  296. HWND hwndFrame; /**< The frame window handle */
  297. } os2;
  298. #endif
  299. #if defined(SDL_VIDEO_DRIVER_VIVANTE)
  300. struct
  301. {
  302. EGLNativeDisplayType display;
  303. EGLNativeWindowType window;
  304. } vivante;
  305. #endif
  306. #if defined(SDL_VIDEO_DRIVER_KMSDRM)
  307. struct
  308. {
  309. int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */
  310. int drm_fd; /**< DRM FD (unavailable on Vulkan windows) */
  311. struct gbm_device *gbm_dev; /**< GBM device (unavailable on Vulkan windows) */
  312. } kmsdrm;
  313. #endif
  314. /* Make sure this union is always 64 bytes (8 64-bit pointers). */
  315. /* Be careful not to overflow this if you add a new target! */
  316. Uint8 dummy[64];
  317. } info;
  318. };
  319. #endif /* SDL_PROTOTYPES_ONLY */
  320. typedef struct SDL_SysWMinfo SDL_SysWMinfo;
  321. /**
  322. * Get driver-specific information about a window.
  323. *
  324. * You must include SDL_syswm.h for the declaration of SDL_SysWMinfo.
  325. *
  326. * The caller must initialize the `info` structure's version by using
  327. * `SDL_VERSION(&info.version)`, and then this function will fill in the rest
  328. * of the structure with information about the given window.
  329. *
  330. * \param window the window about which information is being requested
  331. * \param info an SDL_SysWMinfo structure filled in with window information
  332. * \returns SDL_TRUE if the function is implemented and the `version` member
  333. * of the `info` struct is valid, or SDL_FALSE if the information
  334. * could not be retrieved; call SDL_GetError() for more information.
  335. *
  336. * \since This function is available since SDL 2.0.0.
  337. */
  338. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
  339. SDL_SysWMinfo * info);
  340. /* Ends C function definitions when using C++ */
  341. #ifdef __cplusplus
  342. }
  343. #endif
  344. #include "close_code.h"
  345. #endif /* SDL_syswm_h_ */
  346. /* vi: set ts=4 sw=4 expandtab: */