From 5445aebe94d0a72f57f49cf6638e4e3a4ae50e06 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 7 Dec 2024 20:45:08 +1100 Subject: [PATCH] Ensure `windowDidBecomeKey` callback is running on main thread --- mkdocs-website/docs/en/changelog.md | 9 +++++++++ v3/pkg/application/webview_window_darwin.go | 11 ++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mkdocs-website/docs/en/changelog.md b/mkdocs-website/docs/en/changelog.md index 04973b340..f33099dc3 100644 --- a/mkdocs-website/docs/en/changelog.md +++ b/mkdocs-website/docs/en/changelog.md @@ -17,8 +17,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- [darwin] Ensure `windowDidBecomeKey` callback is running on main thread by [@leaanthony](https://github.com/leaanthony) + + ## v3.0.0-alpha.8.3 - 2024-12-07 +### Changed + +- Ensure for of taskfile is used by @leaanthony + ## v3.0.0-alpha.8.2 - 2024-12-07 ### Changed diff --git a/v3/pkg/application/webview_window_darwin.go b/v3/pkg/application/webview_window_darwin.go index 27e97aecc..33a769e59 100644 --- a/v3/pkg/application/webview_window_darwin.go +++ b/v3/pkg/application/webview_window_darwin.go @@ -1278,9 +1278,14 @@ func (w *macosWebviewWindow) run() { // We have to wait until the window is shown before we can remove the shadow var cancel func() cancel = w.parent.OnWindowEvent(events.Mac.WindowDidBecomeKey, func(_ *WindowEvent) { - w.setHasShadow(!options.Mac.DisableShadow) - w.setAlwaysOnTop(options.AlwaysOnTop) - cancel() + InvokeAsync(func() { + if !w.isVisible() { + w.parent.Show() + } + w.setHasShadow(!options.Mac.DisableShadow) + w.setAlwaysOnTop(options.AlwaysOnTop) + cancel() + }) }) } })