fix: switcher could select the wrong thumbnail (closes #1198)
This commit is contained in:
1 parent
7acee37607
commit
4c6777862e
2 files changed
+14
-2
No files matched your search
@@ -49,6 +49,7 @@ class Window {
|
||||
refreshThumbnail()
|
||||
}
|
||||
application.removeWindowslessAppWindow()
|
||||
checkIfFocused(application, wid)
|
||||
debugPrint("Adding window", cgWindowId, title ?? "nil", application.runningApplication.bundleIdentifier ?? "nil")
|
||||
observeEvents()
|
||||
}
|
||||
@@ -64,6 +65,17 @@ class Window {
|
||||
debugPrint("Deinit window", title ?? "nil", application.runningApplication.bundleIdentifier ?? "nil")
|
||||
}
|
||||
|
||||
/// some apps will not trigger AXApplicationActivated, where we usually update application.focusedWindow
|
||||
/// workaround: we check and possibly do it here
|
||||
func checkIfFocused(_ application: Application, _ wid: CGWindowID) {
|
||||
retryAxCallUntilTimeout {
|
||||
let focusedWid = try application.axUiElement?.focusedWindow()?.cgWindowId()
|
||||
if wid == focusedWid {
|
||||
application.focusedWindow = self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isEqualRobust(_ otherWindowAxUiElement: AXUIElement, _ otherWindowWid: CGWindowID?) -> Bool {
|
||||
// the window can be deallocated by the OS, in which case its `CGWindowID` will be `-1`
|
||||
// we check for equality both on the AXUIElement, and the CGWindowID, in order to catch all scenarios
|
||||
|
||||
@@ -180,8 +180,8 @@ class Windows {
|
||||
static func refreshFirstFewThumbnailsSync() {
|
||||
if Preferences.hideThumbnails { return }
|
||||
list.filter { $0.shouldShowTheUser }
|
||||
.prefix(criticalFirstThumbnails)
|
||||
.forEachAsync { window in window.refreshThumbnail() }
|
||||
.prefix(criticalFirstThumbnails)
|
||||
.forEachAsync { window in window.refreshThumbnail() }
|
||||
}
|
||||
|
||||
static func refreshThumbnailsAsync(_ screen: NSScreen, _ currentIndex: Int = criticalFirstThumbnails) {
|
||||
|
||||
Reference in new issue
Block a user