fix: preview.app window may not show when opening many docs

(closes #3276)
This commit is contained in:
lwouis
2024-04-03 20:17:05 +02:00
parent 785cf9c73a
commit 31b5a3df77
2 changed files with 7 additions and 4 deletions
+7
View File
@@ -87,6 +87,7 @@ extension AXUIElement {
(
books(runningApp) ||
keynote(runningApp) ||
preview(runningApp) ||
iina(runningApp) ||
openFlStudio(runningApp, title) ||
crossoverWindow(runningApp, role, subrole, level) ||
@@ -143,6 +144,12 @@ extension AXUIElement {
return runningApp.bundleIdentifier == "com.apple.iWork.Keynote"
}
private static func preview(_ runningApp: NSRunningApplication) -> Bool {
// when opening multiple documents at once with apple Preview,
// one of the window will have level == 1 for some reason
return runningApp.bundleIdentifier == "com.apple.Preview"
}
private static func openFlStudio(_ runningApp: NSRunningApplication, _ title: String?) -> Bool {
// OpenBoard is a ported app which doesn't use standard macOS windows
return runningApp.bundleIdentifier == "com.image-line.flstudio" && (title != nil && title != "")
-4
View File
@@ -8,10 +8,6 @@ extension CGWindowID {
func level() throws -> CGWindowLevel {
var level = CGWindowLevel(0)
CGSGetWindowLevel(cgsMainConnectionId, self, &level)
// in some weird cases, a window can spawn with level == 1, which is not even a publicly listed level
if level == 1 {
throw AxError.runtimeError
}
return level
}