From 4c7f1362b5811c57263e1e09e96089014095503a Mon Sep 17 00:00:00 2001 From: haikusw Date: Wed, 15 Jun 2022 23:56:02 -0700 Subject: [PATCH 1/2] Fix for #3543 Noticed that the window size wasn't returning the new value and that's why using the window size to calculate the size to restore it to we were incrementing the original size by one. Not sure if this breaks the fix that this bigSurOffsetFix was implementing though because I can't replicate that on macOS 12.4 --- Mac/MainWindow/Detail/DetailWebView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mac/MainWindow/Detail/DetailWebView.swift b/Mac/MainWindow/Detail/DetailWebView.swift index 3fd16cb5e..566abdea4 100644 --- a/Mac/MainWindow/Detail/DetailWebView.swift +++ b/Mac/MainWindow/Detail/DetailWebView.swift @@ -90,7 +90,7 @@ final class DetailWebView: WKWebView { frame.size = NSSize(width: window!.frame.width, height: window!.frame.height - 1) window!.setFrame(frame, display: false) - frame.size = NSSize(width: window!.frame.width, height: window!.frame.height + 1) + frame.size = NSSize(width: frame.width, height: frame.height + 1) window!.setFrame(frame, display: false) } } From 3b9465f21e3a0bedd501e67e4a8175579e6995e9 Mon Sep 17 00:00:00 2001 From: haikusw Date: Mon, 20 Jun 2022 23:12:56 -0700 Subject: [PATCH 2/2] Add #unavailable check so bug fix only executes in macOS 11. Add @available to flag when we can remove this bug-fix code altogether. --- Mac/MainWindow/Detail/DetailWebView.swift | 38 +++++++++++++---------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Mac/MainWindow/Detail/DetailWebView.swift b/Mac/MainWindow/Detail/DetailWebView.swift index 566abdea4..9c7a618b9 100644 --- a/Mac/MainWindow/Detail/DetailWebView.swift +++ b/Mac/MainWindow/Detail/DetailWebView.swift @@ -65,6 +65,7 @@ final class DetailWebView: WKWebView { private var inBigSurOffsetFix = false + @available(macOS, obsoleted: 12, message: "when minimum deployment > macOS 11 remove bigSurOffsetFix() and calls to it.") private func bigSurOffsetFix() { /* On macOS 11, when a user exits full screen @@ -73,25 +74,30 @@ final class DetailWebView: WKWebView { This code adjusts the height of the window by -1pt/+1pt, which puts the webview back in the correct place. + + This code is only executed if currently running on macOS 11 */ - guard var frame = window?.frame else { - return - } - - guard !inBigSurOffsetFix else { - return - } - inBigSurOffsetFix = true - - defer { - inBigSurOffsetFix = false + if #unavailable(macOS 12) { + guard var frame = window?.frame else { + return + } + + guard !inBigSurOffsetFix else { + return + } + + inBigSurOffsetFix = true + + defer { + inBigSurOffsetFix = false + } + + frame.size = NSSize(width: window!.frame.width, height: window!.frame.height - 1) + window!.setFrame(frame, display: false) + frame.size = NSSize(width: frame.width, height: frame.height + 1) + window!.setFrame(frame, display: false) } - - frame.size = NSSize(width: window!.frame.width, height: window!.frame.height - 1) - window!.setFrame(frame, display: false) - frame.size = NSSize(width: frame.width, height: frame.height + 1) - window!.setFrame(frame, display: false) } }