@@ -17,7 +17,6 @@ public final class OverlayWindowController {
1717 var ideWindowOverlayWindowControllers : [ URL : IDEWorkspaceWindowOverlayWindowController ] = [ : ]
1818 var updateWindowStateTask : Task < Void , Error > ?
1919
20- @MainActor
2120 lazy var fullscreenDetector = {
2221 let it = NSWindow (
2322 contentRect: . zero,
@@ -40,17 +39,6 @@ public final class OverlayWindowController {
4039 observeEvents ( )
4140 _ = fullscreenDetector
4241 }
43-
44- public func removeController( for url: URL ) {
45- if let controller = ideWindowOverlayWindowControllers [ url] {
46- controller. destroy ( )
47- ideWindowOverlayWindowControllers. removeValue ( forKey: url)
48- }
49- }
50-
51- public func removeAllControllers( ) {
52- ideWindowOverlayWindowControllers. removeAll ( )
53- }
5442
5543 public nonisolated static func registerIDEWorkspaceWindowOverlayWindowControllerContentProviderFactory(
5644 _ factory: @escaping IDEWorkspaceWindowOverlayWindowControllerContentProviderFactory
@@ -110,8 +98,17 @@ private extension OverlayWindowController {
11098 defer { self . observeWindowChange ( ) }
11199
112100 guard XcodeInspector . shared. activeApplication? . isXcode ?? false else {
113- for (_, controller) in self . ideWindowOverlayWindowControllers {
114- controller. dim ( )
101+ var closedControllers : [ URL ] = [ ]
102+ for (url, controller) in self . ideWindowOverlayWindowControllers {
103+ if controller. isWindowClosed {
104+ controller. dim ( )
105+ closedControllers. append ( url)
106+ } else {
107+ controller. dim ( )
108+ }
109+ }
110+ for url in closedControllers {
111+ self . removeIDEOverlayWindowController ( for: url)
115112 }
116113 return
117114 }
@@ -169,6 +166,13 @@ private extension OverlayWindowController {
169166 newController. access ( )
170167 ideWindowOverlayWindowControllers [ workspaceURL] = newController
171168 }
169+
170+ func removeIDEOverlayWindowController( for workspaceURL: URL ) {
171+ if let controller = ideWindowOverlayWindowControllers [ workspaceURL] {
172+ controller. destroy ( )
173+ }
174+ ideWindowOverlayWindowControllers [ workspaceURL] = nil
175+ }
172176
173177 func handleSpaceChange( ) async {
174178 let windowInspector = XcodeInspector . shared. focusedWindow
0 commit comments