1 /+ 2 + Copyright 2022 – 2023 Aya Partridge 3 + Copyright 2018 - 2022 Michael D. Parker 4 + Distributed under the Boost Software License, Version 1.0. 5 + (See accompanying file LICENSE_1_0.txt or copy at 6 + http://www.boost.org/LICENSE_1_0.txt) 7 +/ 8 module sdl.syswm; 9 10 import bindbc.sdl.config; 11 import bindbc.sdl.codegen; 12 13 import sdl.stdinc: SDL_bool; 14 import sdl.version_: SDL_version; 15 import sdl.video: SDL_Window; 16 17 version(Windows){ 18 import core.sys.windows.windef: HWND, UINT, WPARAM, LPARAM, HDC, HINSTANCE; 19 } 20 21 alias SDL_SYSWM_TYPE = int; 22 enum: SDL_SYSWM_TYPE{ 23 SDL_SYSWM_UNKNOWN = 0, 24 SDL_SYSWM_WINDOWS = 1, 25 SDL_SYSWM_X11 = 2, 26 SDL_SYSWM_DIRECTFB = 3, 27 SDL_SYSWM_COCOA = 4, 28 SDL_SYSWM_UIKIT = 5, 29 } 30 static if(sdlSupport >= SDLSupport.v2_0_2) 31 enum: SDL_SYSWM_TYPE{ 32 SDL_SYSWM_WAYLAND = 6, 33 SDL_SYSWM_MIR = 7, 34 } 35 static if(sdlSupport >= SDLSupport.v2_0_3) 36 enum: SDL_SYSWM_TYPE{ 37 SDL_SYSWM_WINRT = 8, 38 } 39 static if(sdlSupport >= SDLSupport.v2_0_4) 40 enum: SDL_SYSWM_TYPE{ 41 SDL_SYSWM_ANDROID = 9, 42 } 43 static if(sdlSupport >= SDLSupport.v2_0_5) 44 enum: SDL_SYSWM_TYPE{ 45 SDL_SYSWM_VIVANTE = 10, 46 } 47 static if(sdlSupport >= SDLSupport.v2_0_6) 48 enum: SDL_SYSWM_TYPE{ 49 SDL_SYSWM_OS2 = 11, 50 } 51 static if(sdlSupport >= SDLSupport.v2_0_12) 52 enum: SDL_SYSWM_TYPE{ 53 SDL_SYSWM_HAIKU = 12, 54 } 55 static if(sdlSupport >= SDLSupport.v2_0_16) 56 enum: SDL_SYSWM_TYPE{ 57 SDL_SYSWM_KMSDRM = 13, 58 } 59 static if(sdlSupport >= SDLSupport.v2_0_18) 60 enum: SDL_SYSWM_TYPE{ 61 SDL_SYSWM_RISCOS = 14, 62 } 63 64 struct SDL_SysWMmsg{ 65 SDL_version version_; 66 SDL_SYSWM_TYPE subsystem; 67 union _Msg{ 68 version(Windows){ 69 struct _Win{ 70 HWND hwnd; 71 UINT msg; 72 WPARAM wParam; 73 LPARAM lParam; 74 } 75 _Win win; 76 } 77 version(linux){ 78 version(SDL_NoX11){} 79 else: 80 struct _X11{ 81 //XEvent event; 82 int pad1; 83 c_long[24] pad2; 84 } 85 _X11 x11; 86 } 87 version(DirectFB){ 88 struct _DFB{ 89 //DFBEvent event; 90 int clazz; //DFBEventClass clazz; 91 void* pad; 92 } 93 _DFB dfb; 94 } 95 version(OSX){ 96 struct _Cocoa{ 97 int dummy; 98 } 99 _Cocoa cocoa; 100 } 101 version(iOS){ 102 struct _UIKit{ 103 int dummy; 104 } 105 _UIKit uikit; 106 } 107 static if(sdlSupport >= SDLSupport.v2_0_5) version(Vivante){ 108 struct _Vivante{ 109 int dummy; 110 } 111 _Vivante vivante; 112 } 113 static if(sdlSupport >= SDLSupport.v2_0_14) version(OS2){ 114 struct _OS2{ 115 c_ulong fFrame; //BOOL fFrame; 116 c_ulong hwnd; //HWND hwnd; 117 c_ulong msg; //ULONG msg; 118 void* mp1; //MPARAM mp1; 119 void* mp2; //MPARAM mp2; 120 } 121 _OS2 os2; 122 } 123 int dummy; 124 } 125 _Msg msg; 126 } 127 128 struct SDL_SysWMinfo{ 129 SDL_version version_; 130 SDL_SYSWM_TYPE subsystem; 131 132 union _Info{ 133 version(Windows){ 134 struct _Win{ 135 HWND window; 136 static if(sdlSupport >= SDLSupport.v2_0_4): 137 HDC hdc; 138 static if(sdlSupport >= SDLSupport.v2_0_6): 139 HINSTANCE hinstance; 140 } 141 _Win win; 142 } 143 version(WinRT){ 144 struct _WinRT{ 145 void* window; 146 } 147 _WinRT winrt; 148 } 149 version(linux){ 150 version(SDL_NoX11){} 151 else: 152 struct _X11{ 153 void* display; 154 uint window; 155 } 156 _X11 x11; 157 } 158 version(DirectFB){ 159 struct _DFB{ 160 void* dfb; 161 void* window; 162 void* surface; 163 } 164 _DFB dfb; 165 } 166 version(OSX){ 167 struct _Cocoa{ 168 void* window; 169 } 170 _Cocoa cocoa; 171 } 172 version(iOS){ 173 struct _UIKit{ 174 void* window; 175 static if(sdlSupport >= SDLSupport.v2_0_4){ 176 uint framebuffer; 177 uint colorbuffer; 178 alias colourbuffer = colorbuffer; 179 uint resolveFramebuffer; 180 } 181 } 182 _UIKit uikit; 183 } 184 static if(sdlSupport >= SDLSupport.v2_0_2) version(linux){ 185 struct _WL{ 186 void* display; 187 void* surface; 188 void* shell_surface; 189 static if(sdlSupport >= SDLSupport.v2_0_16): 190 void* egl_window; 191 void* xdg_surface; 192 static if(sdlSupport >= SDLSupport.v2_0_18): 193 void* xdg_toplevel; 194 static if(sdlSupport >= SDLSupport.v2_0_22): 195 void* xdg_popup; 196 void* xdg_positioner; 197 } 198 _WL wl; 199 } 200 static if(sdlSupport >= SDLSupport.v2_0_2) version(Mir){ 201 struct _Mir{ 202 void* connection; 203 void* surface; 204 } 205 _Mir mir; 206 } 207 static if(sdlSupport >= SDLSupport.v2_0_4) version(Android){ 208 struct _Android{ 209 void* window; 210 void* surface; 211 } 212 _Android android; 213 } 214 static if(sdlSupport >= SDLSupport.v2_0_14) version(OS2){ 215 struct _OS2{ 216 void* hwnd; //HWND hwnd; 217 void* hwndFrame; //HWND hwndFrame; 218 } 219 _OS2 os2; 220 } 221 static if(sdlSupport >= SDLSupport.v2_0_5) version(Vivante){ 222 struct _Vivante{ 223 void* display; 224 void* window; 225 } 226 _Vivante vivante; 227 } 228 static if(sdlSupport >= SDLSupport.v2_0_16) version(KMSDRM){ 229 struct _KMSDRM{ 230 int dev_index; 231 int drm_fd; 232 void* gbm_dev; 233 } 234 _KMSDRM kmsdrm; 235 } 236 static if(sdlSupport >= SDLSupport.v2_0_6) ubyte[64] dummy; 237 else int dummy; 238 } 239 _Info info; 240 } 241 242 mixin(joinFnBinds((){ 243 string[][] ret; 244 ret ~= makeFnBinds([ 245 [q{SDL_bool}, q{SDL_GetWindowWMInfo}, q{SDL_Window* window, SDL_SysWMinfo* info}], 246 ]); 247 return ret; 248 }()));