@@ -3066,6 +3066,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
30663066 minHeight: CGFloat
30673067 ) -> CGRect {
30683068 if targetDisplay.visibleFrame.intersects(frame) {
3069+ // Preserve the user's exact frame when enough of the top of the window
3070+ // remains reachable on-screen; only clamp when the saved frame would
3071+ // reopen with an inaccessible titlebar/top strip.
3072+ if shouldPreserveAccessibleFrame(
3073+ frame: frame,
3074+ targetDisplay: targetDisplay
3075+ ) {
3076+ return frame
3077+ }
30693078 return clampFrame(
30703079 frame,
30713080 within: targetDisplay.visibleFrame,
@@ -3092,6 +3101,38 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
30923101 )
30933102 }
30943103
3104+ private nonisolated static func shouldPreserveAccessibleFrame(
3105+ frame: CGRect,
3106+ targetDisplay: SessionDisplayGeometry,
3107+ minimumVisibleTopStripWidth: CGFloat = 120,
3108+ topStripHeight: CGFloat = 64,
3109+ minimumVisibleTopStripHeight: CGFloat = 24
3110+ ) -> Bool {
3111+ let standardizedFrame = frame.standardized
3112+ guard standardizedFrame.width.isFinite,
3113+ standardizedFrame.height.isFinite,
3114+ standardizedFrame.width > 0,
3115+ standardizedFrame.height > 0,
3116+ standardizedFrame.intersects(targetDisplay.frame) else {
3117+ return false
3118+ }
3119+
3120+ let stripHeight = min(topStripHeight, standardizedFrame.height)
3121+ let topStrip = CGRect(
3122+ x: standardizedFrame.minX,
3123+ y: standardizedFrame.maxY - stripHeight,
3124+ width: standardizedFrame.width,
3125+ height: stripHeight
3126+ )
3127+ let visibleTopStrip = topStrip.intersection(targetDisplay.visibleFrame)
3128+ guard !visibleTopStrip.isNull else { return false }
3129+
3130+ let requiredWidth = min(minimumVisibleTopStripWidth, standardizedFrame.width)
3131+ let requiredHeight = min(minimumVisibleTopStripHeight, stripHeight)
3132+ return visibleTopStrip.width >= requiredWidth
3133+ && visibleTopStrip.height >= requiredHeight
3134+ }
3135+
30953136 private nonisolated static func display(
30963137 for snapshot: SessionDisplaySnapshot?,
30973138 in displays: [SessionDisplayGeometry]
0 commit comments