From 27b9326d07024f2e34d745985a5970b22c905f52 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 8 Mar 2021 10:06:30 +0800 Subject: [PATCH] fixes #2823 --- .../Detail/DetailWebViewController.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 5c6f9a5ed..674067a4f 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -116,7 +116,7 @@ final class DetailWebViewController: NSViewController, WKUIDelegate { NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(bigSurOffsetFix(_:)), name: NSWindow.didExitFullScreenNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(bigSurOffsetFix(_:)), name: NSWindow.didChangeScreenNotification, object: nil) webView.loadFileURL(ArticleRenderer.blank.url, allowingReadAccessTo: ArticleRenderer.blank.baseURL) } @@ -142,15 +142,19 @@ final class DetailWebViewController: NSViewController, WKUIDelegate { } } - /// On macOS 11, when a user exits full screen, the webview's origin.y is offset by a sizeable amount. This function adjusts the height of the window height by 1pt which puts the webview back in the correct place. This is an issue with SwiftUI and AppKit. + /// On macOS 11, when a user exits full screen or zoomed mode (full screen with menu bar showing), the webview's origin.y is offset by a sizeable amount. This function adjusts the height of the window height by 1pt which puts the webview back in the correct place. This is an issue with SwiftUI and AppKit. @objc func bigSurOffsetFix(_ note: Notification) { if #available(macOS 11, *) { - guard var frame = self.view.window?.frame else { + print(note.name) + guard var frame = view.window?.frame else { return } - frame.size = NSSize(width: self.view.window!.frame.width, height: self.view.window!.frame.height - 1) - self.view.window!.setFrame(frame, display: true) + frame.size = NSSize(width: view.window!.frame.width, height: view.window!.frame.height - 1) + view.window!.setFrame(frame, display: false) + frame.size = NSSize(width: view.window!.frame.width, height: view.window!.frame.height + 1) + view.window!.setFrame(frame, display: false) } + } // MARK: Media Functions