Skip to content

Commit

Permalink
Fix mac window show/hide event mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Jan 12, 2025
1 parent 9569d48 commit 760b587
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 7 additions & 13 deletions v3/pkg/application/webview_window_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ - (NSString *)keyStringFromEvent:(NSEvent *)event {
case 24: return @"=";
case 50: return @"`";
case 42: return @"\\";

default: return @"";
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion v3/pkg/events/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 760b587

Please sign in to comment.