Skip to content

Commit 9e0739e

Browse files
authored
Add map for webview_get_window() (#53)
1 parent e9ec023 commit 9e0739e

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/SharpWebview/Bindings.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,20 @@ internal extern static void webview_return(IntPtr webview,
242242
RPCResult result,
243243
[MarshalAs(UnmanagedType.LPUTF8Str)] string resultJson);
244244

245-
/*
246-
Not mapped:
247-
248-
// Returns a native window handle pointer. When using GTK backend the pointer
249-
// is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow
250-
// pointer, when using Win32 backend the pointer is HWND pointer.
251-
WEBVIEW_API void *webview_get_window(webview_t w);
252-
*/
245+
/// <summary>
246+
/// <para>
247+
/// Returns a native window handle pointer. When using GTK backend the pointer
248+
/// is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow
249+
/// pointer, when using Win32 backend the pointer is HWND pointer.
250+
/// </para>
251+
/// <para>
252+
/// Binding for:
253+
/// WEBVIEW_API void *webview_get_window(webview_t w);
254+
/// </para>
255+
/// </summary>
256+
/// <param name="webview">The webview to get the handle.</param>
257+
/// <returns></returns>
258+
[DllImport(DllFile, CallingConvention = CallingConvention.Cdecl)]
259+
internal extern static IntPtr webview_get_window(IntPtr webview);
253260
}
254261
}

src/SharpWebview/Webview.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ public void Dispatch(Action dispatchFunc)
173173
Bindings.webview_dispatch(_nativeWebview, dispatchFuncInstance, IntPtr.Zero);
174174
}
175175

176+
/// <summary>
177+
/// Get the native window of the webview.
178+
/// </summary>
179+
/// <returns>Native window handle.</returns>
180+
public IntPtr GetWindow()
181+
{
182+
return Bindings.webview_get_window(_nativeWebview);
183+
}
184+
176185
/// <summary>
177186
/// Disposes the current webview.
178187
/// </summary>

0 commit comments

Comments
 (0)