From 17204bebd034d2947e2e7bb4db37ab50b4029bfc Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 30 Apr 2023 10:17:03 +1000 Subject: [PATCH] [v3 Breaking Change] Add `NativeWindowHandle` method to `WebviewWindow`. --- v3/pkg/application/webview_window.go | 9 +++++++++ v3/pkg/application/webview_window_windows.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/v3/pkg/application/webview_window.go b/v3/pkg/application/webview_window.go index 0dc2b1355..3b22e111d 100644 --- a/v3/pkg/application/webview_window.go +++ b/v3/pkg/application/webview_window.go @@ -1,6 +1,7 @@ package application import ( + "errors" "fmt" "github.com/samber/lo" "sync" @@ -59,6 +60,7 @@ type ( getScreen() (*Screen, error) setFrameless(bool) openContextMenu(menu *Menu, data *ContextMenuData) + nativeWindowHandle() uintptr } ) @@ -693,3 +695,10 @@ func (w *WebviewWindow) RegisterContextMenu(name string, menu *Menu) { defer w.contextMenusLock.Unlock() w.contextMenus[name] = menu } + +func (w *WebviewWindow) NativeWindowHandle() (uintptr, error) { + if w.impl == nil { + return 0, errors.New("native handle unavailable as window is not running") + } + return w.impl.nativeWindowHandle(), nil +} diff --git a/v3/pkg/application/webview_window_windows.go b/v3/pkg/application/webview_window_windows.go index a7b888f75..2a471eb3f 100644 --- a/v3/pkg/application/webview_window_windows.go +++ b/v3/pkg/application/webview_window_windows.go @@ -21,6 +21,10 @@ type windowsWebviewWindow struct { hwnd w32.HWND } +func (w *windowsWebviewWindow) nativeWindowHandle() uintptr { + return w.hwnd +} + func (w *windowsWebviewWindow) setTitle(title string) { //TODO implement me panic("implement me")