SDL_syswm.h 7.0 KB

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