From 610b4cd1c84eed21ace58406f8484358173460ad Mon Sep 17 00:00:00 2001 From: Celve Date: Thu, 5 Dec 2024 23:02:18 -0800 Subject: [PATCH] fix: correct position error in macOS14 --- Peninsula.xcodeproj/project.pbxproj | 4 ++-- Peninsula/Notch/NotchWindowController.swift | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Peninsula.xcodeproj/project.pbxproj b/Peninsula.xcodeproj/project.pbxproj index 5c64592..d13fa70 100644 --- a/Peninsula.xcodeproj/project.pbxproj +++ b/Peninsula.xcodeproj/project.pbxproj @@ -308,7 +308,7 @@ CODE_SIGN_ENTITLEMENTS = Peninsula/Peninsula.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"Peninsula/Preview Content\""; DEVELOPMENT_TEAM = 8TDYAWS6VC; ENABLE_HARDENED_RUNTIME = YES; @@ -340,7 +340,7 @@ CODE_SIGN_ENTITLEMENTS = Peninsula/Peninsula.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"Peninsula/Preview Content\""; DEVELOPMENT_TEAM = 8TDYAWS6VC; ENABLE_HARDENED_RUNTIME = YES; diff --git a/Peninsula/Notch/NotchWindowController.swift b/Peninsula/Notch/NotchWindowController.swift index 43352de..bc826d3 100644 --- a/Peninsula/Notch/NotchWindowController.swift +++ b/Peninsula/Notch/NotchWindowController.swift @@ -8,6 +8,7 @@ import Cocoa private let notchHeight: CGFloat = 800 +private let notchWidth: CGFloat = 150 class NotchWindowController: NSWindowController { var vm: NotchViewModel? @@ -26,7 +27,7 @@ class NotchWindowController: NSWindowController { contentViewController = NotchViewController(vm) if notchSize == .zero { - notchSize = .init(width: 150, height: 24) + notchSize = .init(width: notchWidth, height: 24) } vm.deviceNotchRect = CGRect( x: screen.frame.origin.x + (screen.frame.width - notchSize.width) / 2, @@ -63,8 +64,10 @@ class NotchWindowController: NSWindowController { width: screen.frame.width, height: notchHeight ) - window.setFrameOrigin(topRect.origin) + + // set content size first, otherwise whether it expands from top-right or from bottom-left is inconsistent between macOS major versions window.setContentSize(topRect.size) + window.setFrameOrigin(topRect.origin) } deinit {