From 760b58726ad66d4b4a950393191938a210b23f1a Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 12 Jan 2025 20:30:55 +1100 Subject: [PATCH] Fix mac window show/hide event mapping. --- v3/pkg/application/webview_window_darwin.m | 20 +++++++------------- v3/pkg/events/defaults.go | 3 ++- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/v3/pkg/application/webview_window_darwin.m b/v3/pkg/application/webview_window_darwin.m index a7b9f5010a9..775ebe1d9e5 100644 --- a/v3/pkg/application/webview_window_darwin.m +++ b/v3/pkg/application/webview_window_darwin.m @@ -162,6 +162,7 @@ - (NSString *)keyStringFromEvent:(NSEvent *)event { case 24: return @"="; case 50: return @"`"; case 42: return @"\\"; + default: return @""; } } @@ -283,14 +284,13 @@ - (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenP return proposedOptions | NSApplicationPresentationAutoHideToolbar; } } -- (void)windowDidChangeVisibility:(NSNotification *)notification { +- (void)windowDidChangeOcclusionState:(NSNotification *)notification { NSWindow *window = notification.object; - BOOL isVisible = ![window isVisible]; + BOOL isVisible = ([window occlusionState] & NSWindowOcclusionStateVisible) != 0; if (hasListeners(isVisible ? EventWindowShow : EventWindowHide)) { processWindowEvent(self.windowId, isVisible ? EventWindowShow : EventWindowHide); } } -// GENERATED EVENTS START - (void)windowDidBecomeKey:(NSNotification *)notification { if( hasListeners(EventWindowDidBecomeKey) ) { processWindowEvent(self.windowId, EventWindowDidBecomeKey); @@ -339,12 +339,6 @@ - (void)windowDidChangeEffectiveAppearance:(NSNotification *)notification { } } -- (void)windowDidChangeOcclusionState:(NSNotification *)notification { - if( hasListeners(EventWindowDidChangeOcclusionState) ) { - processWindowEvent(self.windowId, EventWindowDidChangeOcclusionState); - } -} - - (void)windowDidChangeOrderingMode:(NSNotification *)notification { if( hasListeners(EventWindowDidChangeOrderingMode) ) { processWindowEvent(self.windowId, EventWindowDidChangeOrderingMode); @@ -747,25 +741,25 @@ - (void)windowHide:(NSNotification *)notification { } } -- (void)webView:(WKWebView *)webview didStartProvisionalNavigation:(WKNavigation *)navigation { +- (void)webView:(nonnull WKWebView *)webview didStartProvisionalNavigation:(WKNavigation *)navigation { if( hasListeners(EventWebViewDidStartProvisionalNavigation) ) { processWindowEvent(self.windowId, EventWebViewDidStartProvisionalNavigation); } } -- (void)webView:(WKWebView *)webview didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation { +- (void)webView:(nonnull WKWebView *)webview didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation { if( hasListeners(EventWebViewDidReceiveServerRedirectForProvisionalNavigation) ) { processWindowEvent(self.windowId, EventWebViewDidReceiveServerRedirectForProvisionalNavigation); } } -- (void)webView:(WKWebView *)webview didFinishNavigation:(WKNavigation *)navigation { +- (void)webView:(nonnull WKWebView *)webview didFinishNavigation:(WKNavigation *)navigation { if( hasListeners(EventWebViewDidFinishNavigation) ) { processWindowEvent(self.windowId, EventWebViewDidFinishNavigation); } } -- (void)webView:(WKWebView *)webview didCommitNavigation:(WKNavigation *)navigation { +- (void)webView:(nonnull WKWebView *)webview didCommitNavigation:(WKNavigation *)navigation { if( hasListeners(EventWebViewDidCommitNavigation) ) { processWindowEvent(self.windowId, EventWebViewDidCommitNavigation); } diff --git a/v3/pkg/events/defaults.go b/v3/pkg/events/defaults.go index 0600dc71538..7fafc284453 100644 --- a/v3/pkg/events/defaults.go +++ b/v3/pkg/events/defaults.go @@ -33,8 +33,9 @@ var defaultWindowEventMapping = map[string]map[WindowEventType]WindowEventType{ Mac.WindowUnMaximise: Common.WindowUnMaximise, Mac.WindowDidMove: Common.WindowDidMove, Mac.WindowDidResize: Common.WindowDidResize, - Mac.WindowDidUpdate: Common.WindowShow, Mac.WindowDidZoom: Common.WindowMaximise, + Mac.WindowShow: Common.WindowShow, + Mac.WindowHide: Common.WindowHide, Mac.WindowZoomIn: Common.WindowZoomIn, Mac.WindowZoomOut: Common.WindowZoomOut, Mac.WindowZoomReset: Common.WindowZoomReset,