From 6504a67f0bb9551db9caf0234898a321b2e9c250 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 27 Oct 2023 14:56:30 -0700 Subject: [PATCH] macos: set proper cascade point when closing tab in window Fixes #745 --- .../Features/Primary Window/PrimaryWindowManager.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift b/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift index 1489b09dc..eef81f449 100644 --- a/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift +++ b/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift @@ -183,6 +183,16 @@ class PrimaryWindowManager { // If we remove a window, we reset the cascade point to the key window so that // the next window cascade's from that one. if let focusedWindow = NSApplication.shared.keyWindow { + // If we are NOT the focused window, then we are a tabbed window. If we + // are closing a tabbed window, we want to set the cascade point to be + // the next cascade point from this window. + if focusedWindow != window { + Self.lastCascadePoint = focusedWindow.cascadeTopLeft(from: NSZeroPoint) + return + } + + // If we are the focused window, then we set the last cascade point to + // our own frame so that it shows up in the same spot. let frame = focusedWindow.frame Self.lastCascadePoint = NSPoint(x: frame.minX, y: frame.maxY) }