@@ -277,12 +277,6 @@ extension WindowManager {
277
277
278
278
fileprivate func remove( window: Window ) {
279
279
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
-
286
280
windows. regenerateActiveIDCache ( )
287
281
windows. remove ( window: window)
288
282
}
@@ -381,11 +375,6 @@ extension WindowManager {
381
375
}
382
376
383
377
private func add( window: Window , retries: Int = 5 ) {
384
- guard !windows. isWindowTracked ( window) else {
385
- log. warning ( " skipping window " )
386
- return
387
- }
388
-
389
378
guard window. shouldBeManaged ( ) else {
390
379
return
391
380
}
@@ -395,6 +384,14 @@ extension WindowManager {
395
384
return
396
385
}
397
386
387
+ defer {
388
+ windows. regenerateActiveIDCache ( )
389
+ }
390
+
391
+ guard !windows. isWindowTracked ( window) else {
392
+ return
393
+ }
394
+
398
395
switch application. defaultFloatForWindow ( window) {
399
396
case . unreliable where retries > 0 :
400
397
return DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.05 ) {
@@ -406,21 +403,8 @@ extension WindowManager {
406
403
windows. setFloating ( false , forWindow: window)
407
404
}
408
405
409
- windows. regenerateActiveIDCache ( )
410
406
windows. add ( window: window, atFront: userConfiguration. sendNewWindowsToMainPane ( ) )
411
407
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
-
424
408
guard let screen = window. screen ( ) else {
425
409
return
426
410
}
0 commit comments