diff --git a/src/api-wrappers/AXUIElement.swift b/src/api-wrappers/AXUIElement.swift index 5da0ce46..5d234e2d 100644 --- a/src/api-wrappers/AXUIElement.swift +++ b/src/api-wrappers/AXUIElement.swift @@ -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 != "") diff --git a/src/api-wrappers/CGWindowID.swift b/src/api-wrappers/CGWindowID.swift index 2ae09a35..ca645b86 100644 --- a/src/api-wrappers/CGWindowID.swift +++ b/src/api-wrappers/CGWindowID.swift @@ -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 }