From b30a936fa623da9212d48c599308a46a1c7156b4 Mon Sep 17 00:00:00 2001 From: Cyy Summer Date: Sat, 25 Oct 2025 11:14:46 +0800 Subject: [PATCH] Add map for webview_get_window() --- src/SharpWebview/Bindings.cs | 23 +++++++++++++++-------- src/SharpWebview/Webview.cs | 9 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/SharpWebview/Bindings.cs b/src/SharpWebview/Bindings.cs index 1b4c62d..305e20b 100644 --- a/src/SharpWebview/Bindings.cs +++ b/src/SharpWebview/Bindings.cs @@ -242,13 +242,20 @@ internal extern static void webview_return(IntPtr webview, RPCResult result, [MarshalAs(UnmanagedType.LPUTF8Str)] string resultJson); - /* - Not mapped: - - // Returns a native window handle pointer. When using GTK backend the pointer - // is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow - // pointer, when using Win32 backend the pointer is HWND pointer. - WEBVIEW_API void *webview_get_window(webview_t w); - */ + /// + /// + /// Returns a native window handle pointer. When using GTK backend the pointer + /// is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow + /// pointer, when using Win32 backend the pointer is HWND pointer. + /// + /// + /// Binding for: + /// WEBVIEW_API void *webview_get_window(webview_t w); + /// + /// + /// The webview to get the handle. + /// + [DllImport(DllFile, CallingConvention = CallingConvention.Cdecl)] + internal extern static IntPtr webview_get_window(IntPtr webview); } } diff --git a/src/SharpWebview/Webview.cs b/src/SharpWebview/Webview.cs index 3ce1dbb..41ce3bb 100644 --- a/src/SharpWebview/Webview.cs +++ b/src/SharpWebview/Webview.cs @@ -173,6 +173,15 @@ public void Dispatch(Action dispatchFunc) Bindings.webview_dispatch(_nativeWebview, dispatchFuncInstance, IntPtr.Zero); } + /// + /// Get the native window of the webview. + /// + /// Native window handle. + public IntPtr GetWindow() + { + return Bindings.webview_get_window(_nativeWebview); + } + /// /// Disposes the current webview. ///