@@ -277,12 +277,6 @@ extension WindowManager {
277277
278278 fileprivate func remove( window: Window ) {
279279 markAllScreensForReflow ( withChange: . remove( window: window) )
280-
281- let application = applicationWithPID ( window. pid ( ) )
282- application? . unobserve ( notification: kAXUIElementDestroyedNotification, window: window)
283- application? . unobserve ( notification: kAXWindowMiniaturizedNotification, window: window)
284- application? . unobserve ( notification: kAXWindowDeminiaturizedNotification, window: window)
285-
286280 windows. regenerateActiveIDCache ( )
287281 windows. remove ( window: window)
288282 }
@@ -381,11 +375,6 @@ extension WindowManager {
381375 }
382376
383377 private func add( window: Window , retries: Int = 5 ) {
384- guard !windows. isWindowTracked ( window) else {
385- log. warning ( " skipping window " )
386- return
387- }
388-
389378 guard window. shouldBeManaged ( ) else {
390379 return
391380 }
@@ -395,6 +384,14 @@ extension WindowManager {
395384 return
396385 }
397386
387+ defer {
388+ windows. regenerateActiveIDCache ( )
389+ }
390+
391+ guard !windows. isWindowTracked ( window) else {
392+ return
393+ }
394+
398395 switch application. defaultFloatForWindow ( window) {
399396 case . unreliable where retries > 0 :
400397 return DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.05 ) {
@@ -406,21 +403,8 @@ extension WindowManager {
406403 windows. setFloating ( false , forWindow: window)
407404 }
408405
409- windows. regenerateActiveIDCache ( )
410406 windows. add ( window: window, atFront: userConfiguration. sendNewWindowsToMainPane ( ) )
411407
412- application. observe ( notification: kAXUIElementDestroyedNotification, window: window) { _ in
413- self . remove ( window: window)
414- }
415- application. observe ( notification: kAXWindowMiniaturizedNotification, window: window) { _ in
416- self . remove ( window: window)
417-
418- guard let screen = window. screen ( ) else {
419- return
420- }
421- self . markScreen ( screen, forReflowWithChange: . remove( window: window) )
422- }
423-
424408 guard let screen = window. screen ( ) else {
425409 return
426410 }
0 commit comments