2
0
Эх сурвалжийг харах

Added GetDisplayHandle() and renamed GetWindowHandle() to GetHandle().

Display handle is required on some platforms (as well as the window handle)  to create graphics contexts.
Brucey 3 жил өмнө
parent
commit
db80525457

+ 1 - 0
sdlvideo.mod/common.bmx

@@ -88,6 +88,7 @@ Extern
 	Function bmx_sdl_video_GetWindowDisplayMode:Byte Ptr(handle:Byte Ptr)
 	Function bmx_sdl_video_SetWindowTitle(handle:Byte Ptr, title:String)
 	Function bmx_sdl_video_GetWindowHandle:Byte Ptr(handle:Byte Ptr)
+	Function bmx_sdl_video_GetWindowDisplayHandle:Byte Ptr(handle:Byte Ptr)
 
 	Function SDL_GetWindowDisplayIndex:Int(handle:Byte Ptr)
 	Function SDL_GetWindowPixelFormat:UInt(handle:Byte Ptr)

+ 21 - 0
sdlvideo.mod/glue.c

@@ -276,6 +276,10 @@ void * bmx_sdl_video_GetWindowHandle(SDL_Window * window) {
 			case SDL_SYSWM_X11:
 				return info.info.x11.window;
 #endif
+#ifdef SDL_VIDEO_DRIVER_WAYLAND
+			case SDL_SYSWM_WAYLAND:
+				return info.info.wl.surface;
+#endif
 #ifdef SDL_VIDEO_DRIVER_DIRECTFB
 			case SDL_SYSWM_DIRECTFB:
 				return info.info.dfb.window;
@@ -297,6 +301,23 @@ void * bmx_sdl_video_GetWindowHandle(SDL_Window * window) {
 	return NULL;
 }
 
+void * bmx_sdl_video_GetWindowDisplayHandle(SDL_Window * window) {
+	struct SDL_SysWMinfo info;
+	SDL_VERSION(&info.version);
+	if (SDL_GetWindowWMInfo(window, &info)) {
+		switch (info.subsystem) {
+#ifdef SDL_VIDEO_DRIVER_X11
+			case SDL_SYSWM_X11:
+				return wmi.info.x11.display;
+#endif
+#ifdef SDL_VIDEO_DRIVER_WAYLAND
+			case SDL_SYSWM_WAYLAND:
+				return wmi.info.wl.display;
+#endif
+		}
+	}
+	return NULL;
+}
 // --------------------------------------------------------
 /*
 // For re-generating pixel formats consts, for sdl.sdl common.bmx

+ 8 - 1
sdlvideo.mod/sdlvideo.bmx

@@ -436,10 +436,17 @@ Type TSDLWindow
 	Rem
 	bbdoc: Returns the native window handle for this window.
 	End Rem
-	Method GetWindowHandle:Byte Ptr()
+	Method GetHandle:Byte Ptr()
 		Return bmx_sdl_video_GetWindowHandle(windowPtr)
 	End Method
 	
+	Rem
+	bbdoc: Returns the native window handle for this window.
+	End Rem
+	Method GetDisplayHandle:Byte Ptr()
+		Return bmx_sdl_video_GetWindowDisplayHandle(windowPtr)
+	End Method
+
 	Rem
 	bbdoc: Moves the mouse cursor to the given position within the window.
 	about: This method generates a mouse motion event.