@@ -5,38 +5,39 @@ func normalizeLayoutReason() async throws {
55 try await _normalizeLayoutReason ( workspace: workspace, windows: windows)
66 }
77 try await _normalizeLayoutReason ( workspace: focus. workspace, windows: macosMinimizedWindowsContainer. children. filterIsInstance ( of: Window . self) )
8- try await demoteNativeTabsToPopup ( )
9- try await validateStillPopups ( )
8+ try await validatePopups ( )
9+ demoteInactiveTabs ( )
1010}
1111
12- /// Move tiled windows that have become inactive native tabs to the popup container.
13- /// This handles the case where a tiled window becomes a background tab after the user opens a new tab.
12+ /// Promote popup windows that are actually real windows (or newly active tabs).
1413/// https://github.com/nikitabobko/AeroSpace/issues/68
1514@MainActor
16- private func demoteNativeTabsToPopup( ) async throws {
17- for workspace in Workspace . all {
18- for window in workspace. allLeafWindowsRecursive {
19- guard let macWindow = window as? MacWindow else { continue }
20- if isLikelyNativeTab ( windowId: macWindow. windowId, appPid: macWindow. macApp. pid) {
21- macWindow. bind ( to: macosPopupWindowsContainer, adaptiveWeight: WEIGHT_AUTO, index: INDEX_BIND_LAST)
22- }
15+ private func validatePopups( ) async throws {
16+ refreshNativeTabDetection ( )
17+ for node in Array ( macosPopupWindowsContainer. children) {
18+ guard let popup = node as? MacWindow else { continue }
19+ // Don't promote inactive native tabs
20+ if isLikelyNativeTab ( windowId: popup. windowId, appPid: popup. macApp. pid, appWindowCount: windowCountForApp ( pid: popup. macApp. pid) ) { continue }
21+ // This window is on-screen and should be promoted to tiling
22+ let windowLevel = getWindowLevel ( for: popup. windowId)
23+ if try await popup. isWindowHeuristic ( windowLevel) {
24+ try await popup. relayoutWindow ( on: focus. workspace)
25+ try await tryOnWindowDetected ( popup)
2326 }
2427 }
2528}
2629
30+ /// Demote tiled windows that have become inactive native tabs to popup container.
31+ /// https://github.com/nikitabobko/AeroSpace/issues/68
2732@MainActor
28- private func validateStillPopups( ) async throws {
29- for node in macosPopupWindowsContainer. children {
30- let popup = ( node as! MacWindow )
31- // Don't promote native tabs back to tiling — they were intentionally placed in popup container
32- // https://github.com/nikitabobko/AeroSpace/issues/68
33- if isLikelyNativeTab ( windowId: popup. windowId, appPid: popup. macApp. pid) {
34- continue
35- }
36- let windowLevel = getWindowLevel ( for: popup. windowId)
37- if try await popup. isWindowHeuristic ( windowLevel) {
38- try await popup. relayoutWindow ( on: focus. workspace)
39- try await tryOnWindowDetected ( popup)
33+ private func demoteInactiveTabs( ) {
34+ refreshNativeTabDetection ( )
35+ for workspace in Workspace . all {
36+ for window in Array ( workspace. allLeafWindowsRecursive) {
37+ guard let macWindow = window as? MacWindow else { continue }
38+ if isLikelyNativeTab ( windowId: macWindow. windowId, appPid: macWindow. macApp. pid, appWindowCount: windowCountForApp ( pid: macWindow. macApp. pid) ) {
39+ macWindow. bind ( to: macosPopupWindowsContainer, adaptiveWeight: WEIGHT_AUTO, index: INDEX_BIND_LAST)
40+ }
4041 }
4142 }
4243}
0 commit comments