From e2f21c15c268fde877cc9c38b41cc20471ed8004 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 8 Mar 2021 14:12:32 +0800 Subject: [PATCH] formatting --- Mac/MainWindow/Detail/DetailWebView.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Mac/MainWindow/Detail/DetailWebView.swift b/Mac/MainWindow/Detail/DetailWebView.swift index 0dde85087..7252adde2 100644 --- a/Mac/MainWindow/Detail/DetailWebView.swift +++ b/Mac/MainWindow/Detail/DetailWebView.swift @@ -54,8 +54,14 @@ final class DetailWebView: WKWebView { super.viewDidEndLiveResize() evaluateJavaScript("document.body.style.overflow = 'visible';", completionHandler: nil) + /* + On macOS 11, when a user exits full screen + or exits zoomed mode by disconnecting an external display + the webview's `origin.y` is offset by a sizeable amount. - // On macOS 11, when a user exits full screen or exits zoomed mode (full screen with menu bar showing) by disconnecting an external display, the webview's origin.y is offset by a sizeable amount. This function adjusts the height of the window height by -1pt/+1pt which puts the webview back in the correct place. This is an issue with SwiftUI and AppKit. + This code adjusts the height of the window by -1pt/+1pt, + which puts the webview back in the correct place. + */ if #available(macOS 11, *) { guard var frame = window?.frame else { return @@ -65,7 +71,6 @@ final class DetailWebView: WKWebView { frame.size = NSSize(width: window!.frame.width, height: window!.frame.height + 1) window!.setFrame(frame, display: false) } - } }