diff --git a/Mac/MainWindow/Detail/DetailWebView.swift b/Mac/MainWindow/Detail/DetailWebView.swift index 3fd16cb5e..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: window!.frame.width, height: window!.frame.height + 1) - window!.setFrame(frame, display: false) } }