fix: don't display invalid windows (may fix #292 #200)

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-05-07 02:00:45 +09:00
1 parent 3a11cc6dbd
commit 1bca012faa
2 files changed
+7

No files matched your search

+6
View File
@@ -94,6 +94,12 @@ class Windows {
}
}
// some window can get invalid *after* we add them to our list, but without us getting notified about it
// workaround: we remove the invalid windows right before showing the UI
static func removeWindowsWhichBecameInvalid() {
Windows.list.removeAll(where: { !$0.axUiElement.isActualWindow($0.application.runningApplication.bundleIdentifier) })
}
static func refreshIfWindowShouldBeShownToTheUser(_ window: Window, _ screen: NSScreen) {
window.shouldShowTheUser = !(!Preferences.showMinimizedWindows && window.isMinimized) &&
!(!Preferences.showHiddenWindows && window.isHidden) &&
+1
View File
@@ -194,6 +194,7 @@ class App: NSApplication, NSApplicationDelegate {
// TODO: find a way to update space index when windows are moved to another space, instead of on every trigger
Windows.updateSpaces()
let screen = Screen.preferred()
Windows.removeWindowsWhichBecameInvalid()
Windows.refreshWhichWindowsToShowTheUser(screen)
if Windows.list.first(where: { $0.shouldShowTheUser }) == nil { hideUi(); return }
Windows.updateFocusedWindowIndex(0)