Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 760b587

Browse files
committedJan 12, 2025··
Fix mac window show/hide event mapping.
1 parent 9569d48 commit 760b587

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed
 

‎v3/pkg/application/webview_window_darwin.m

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ - (NSString *)keyStringFromEvent:(NSEvent *)event {
162162
case 24: return @"=";
163163
case 50: return @"`";
164164
case 42: return @"\\";
165+
165166
default: return @"";
166167
}
167168
}
@@ -283,14 +284,13 @@ - (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenP
283284
return proposedOptions | NSApplicationPresentationAutoHideToolbar;
284285
}
285286
}
286-
- (void)windowDidChangeVisibility:(NSNotification *)notification {
287+
- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
287288
NSWindow *window = notification.object;
288-
BOOL isVisible = ![window isVisible];
289+
BOOL isVisible = ([window occlusionState] & NSWindowOcclusionStateVisible) != 0;
289290
if (hasListeners(isVisible ? EventWindowShow : EventWindowHide)) {
290291
processWindowEvent(self.windowId, isVisible ? EventWindowShow : EventWindowHide);
291292
}
292293
}
293-
// GENERATED EVENTS START
294294
- (void)windowDidBecomeKey:(NSNotification *)notification {
295295
if( hasListeners(EventWindowDidBecomeKey) ) {
296296
processWindowEvent(self.windowId, EventWindowDidBecomeKey);
@@ -339,12 +339,6 @@ - (void)windowDidChangeEffectiveAppearance:(NSNotification *)notification {
339339
}
340340
}
341341

342-
- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
343-
if( hasListeners(EventWindowDidChangeOcclusionState) ) {
344-
processWindowEvent(self.windowId, EventWindowDidChangeOcclusionState);
345-
}
346-
}
347-
348342
- (void)windowDidChangeOrderingMode:(NSNotification *)notification {
349343
if( hasListeners(EventWindowDidChangeOrderingMode) ) {
350344
processWindowEvent(self.windowId, EventWindowDidChangeOrderingMode);
@@ -747,25 +741,25 @@ - (void)windowHide:(NSNotification *)notification {
747741
}
748742
}
749743

750-
- (void)webView:(WKWebView *)webview didStartProvisionalNavigation:(WKNavigation *)navigation {
744+
- (void)webView:(nonnull WKWebView *)webview didStartProvisionalNavigation:(WKNavigation *)navigation {
751745
if( hasListeners(EventWebViewDidStartProvisionalNavigation) ) {
752746
processWindowEvent(self.windowId, EventWebViewDidStartProvisionalNavigation);
753747
}
754748
}
755749

756-
- (void)webView:(WKWebView *)webview didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation {
750+
- (void)webView:(nonnull WKWebView *)webview didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation {
757751
if( hasListeners(EventWebViewDidReceiveServerRedirectForProvisionalNavigation) ) {
758752
processWindowEvent(self.windowId, EventWebViewDidReceiveServerRedirectForProvisionalNavigation);
759753
}
760754
}
761755

762-
- (void)webView:(WKWebView *)webview didFinishNavigation:(WKNavigation *)navigation {
756+
- (void)webView:(nonnull WKWebView *)webview didFinishNavigation:(WKNavigation *)navigation {
763757
if( hasListeners(EventWebViewDidFinishNavigation) ) {
764758
processWindowEvent(self.windowId, EventWebViewDidFinishNavigation);
765759
}
766760
}
767761

768-
- (void)webView:(WKWebView *)webview didCommitNavigation:(WKNavigation *)navigation {
762+
- (void)webView:(nonnull WKWebView *)webview didCommitNavigation:(WKNavigation *)navigation {
769763
if( hasListeners(EventWebViewDidCommitNavigation) ) {
770764
processWindowEvent(self.windowId, EventWebViewDidCommitNavigation);
771765
}

‎v3/pkg/events/defaults.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ var defaultWindowEventMapping = map[string]map[WindowEventType]WindowEventType{
3333
Mac.WindowUnMaximise: Common.WindowUnMaximise,
3434
Mac.WindowDidMove: Common.WindowDidMove,
3535
Mac.WindowDidResize: Common.WindowDidResize,
36-
Mac.WindowDidUpdate: Common.WindowShow,
3736
Mac.WindowDidZoom: Common.WindowMaximise,
37+
Mac.WindowShow: Common.WindowShow,
38+
Mac.WindowHide: Common.WindowHide,
3839
Mac.WindowZoomIn: Common.WindowZoomIn,
3940
Mac.WindowZoomOut: Common.WindowZoomOut,
4041
Mac.WindowZoomReset: Common.WindowZoomReset,

0 commit comments

Comments
 (0)
Please sign in to comment.