Newer
Older
sample / sdl-d / import / sdl / c / sdl_syswm.d
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2006 Sam Lantinga
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18.  
  19. Sam Lantinga
  20. slouken@libsdl.org
  21. */
  22. module sdl.c.sdl_syswm;
  23.  
  24. /* Include file for SDL custom system window manager hooks */
  25.  
  26. public
  27. {
  28. import sdl.c.sdl_stdinc;
  29. import sdl.c.sdl_error;
  30. import sdl.c.sdl_version;
  31. }
  32.  
  33. extern(C):
  34.  
  35. /* Your application has access to a special type of event 'SDL_SYSWMEVENT',
  36. which contains window-manager specific information and arrives whenever
  37. an unhandled window event occurs. This event is ignored by default, but
  38. you can enable it with SDL_EventState()
  39. */
  40.  
  41. version (Windows)
  42. {
  43. public import std.c.windows.windows;
  44.  
  45. /* The windows custom event structure */
  46. struct SDL_SysWMmsg {
  47. SDL_version _version;
  48. HWND hwnd; /* The window for the message */
  49. UINT msg; /* The type of message */
  50. WPARAM wParam; /* WORD message parameter */
  51. LPARAM lParam; /* LONG message parameter */
  52. }
  53.  
  54. /* The windows custom window manager information structure */
  55. struct SDL_SysWMinfo {
  56. SDL_version _version;
  57. HWND window; /* The Win32 display window */
  58. HGLRC hglrc; /* The OpenGL context, if any */
  59. }
  60.  
  61. }
  62. else version(Linux)
  63. {
  64.  
  65. /* These are the various supported subsystems under UNIX */
  66. enum SDL_SYSWM_TYPE {
  67. SDL_SYSWM_X11
  68. }
  69.  
  70. /* The UNIX custom event structure */
  71. struct SDL_SysWMmsg {
  72. SDL_version _version;
  73. SDL_SYSWM_TYPE subsystem;
  74. union Event {
  75. XEvent xevent;
  76. }
  77. Event event;
  78. };
  79.  
  80. /* The UNIX custom window manager information structure.
  81. When this structure is returned, it holds information about which
  82. low level system it is using, and will be one of SDL_SYSWM_TYPE.
  83. */
  84. struct SDL_SysWMinfo {
  85. SDL_version _version;
  86. SDL_SYSWM_TYPE subsystem;
  87. union Info {
  88. struct X11 {
  89. Display *display; /* The X11 display */
  90. Window window; /* The X11 display window */
  91. /* These locking functions should be called around
  92. any X11 functions using the display variable,
  93. but not the gfxdisplay variable.
  94. They lock the event thread, so should not be
  95. called around event functions or from event filters.
  96. */
  97. void function(void) lock_func;
  98. void function(void) unlock_func;
  99.  
  100. /* Introduced in SDL 1.0.2 */
  101. Window fswindow; /* The X11 fullscreen window */
  102. Window wmwindow; /* The X11 managed input window */
  103.  
  104. /* Introduced in SDL 1.2.12 */
  105. Display *gfxdisplay; /* The X11 display to which rendering is done */
  106. }
  107. X11 x11;
  108. }
  109. Info info;
  110. }
  111. }
  112. else
  113. {
  114. /* The generic custom event structure */
  115. struct SDL_SysWMmsg {
  116. SDL_version _version;
  117. int data;
  118. }
  119.  
  120. /* The generic custom window manager information structure */
  121. struct SDL_SysWMinfo {
  122. SDL_version _version;
  123. int data;
  124. }
  125. }
  126.  
  127.  
  128. /* Function prototypes */
  129. /*
  130. * This function gives you custom hooks into the window manager information.
  131. * It fills the structure pointed to by 'info' with custom information and
  132. * returns 1 if the function is implemented. If it's not implemented, or
  133. * the version member of the 'info' structure is invalid, it returns 0.
  134. *
  135. * You typically use this function like this:
  136. * SDL_SysWMInfo info;
  137. * SDL_VERSION(&info.version);
  138. * if ( SDL_GetWMInfo(&info) ) { ... }
  139. */
  140. int SDL_GetWMInfo(SDL_SysWMinfo *info);
  141.