From 9e92dfaefd25193c8e79d39e8ea8c03a7a560c13 Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Tue, 25 Aug 2020 01:26:00 +0900 Subject: [PATCH] fix: books.app windows were not always showing (closes #481) --- src/api-wrappers/AXUIElement.swift | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/api-wrappers/AXUIElement.swift b/src/api-wrappers/AXUIElement.swift index bf4ec1af0..999a79037 100644 --- a/src/api-wrappers/AXUIElement.swift +++ b/src/api-wrappers/AXUIElement.swift @@ -53,17 +53,23 @@ extension AXUIElement { // Some non-windows have cgWindowId == 0 (e.g. windows of apps starting at login with the checkbox "Hidden" checked) return wid != 0 && + books(runningApp) || ( // CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows isOnNormalLevel && - (["AXStandardWindow", "AXDialog"].contains(subrole) || - steam(runningApp, title, role) || - worldOfWarcraft(runningApp, role) || - battleNetBootstrapper(runningApp, role) || - firefoxFullscreenVideo(runningApp, role) || - androidEmulator(runningApp, title) || - sanGuoShaAirWD(runningApp) || - dvdFab(runningApp) || - drBetotte(runningApp)) + (["AXStandardWindow", "AXDialog"].contains(subrole) || + steam(runningApp, title, role) || + worldOfWarcraft(runningApp, role) || + battleNetBootstrapper(runningApp, role) || + firefoxFullscreenVideo(runningApp, role) || + androidEmulator(runningApp, title) || + sanGuoShaAirWD(runningApp) || + dvdFab(runningApp) || + drBetotte(runningApp))) + } + + private func books(_ runningApp: NSRunningApplication) -> Bool { + // Books.app has animations on window creation. This means windows are originally created with subrole == AXUnknown or isOnNormalLevel == false + return runningApp.bundleIdentifier == "com.apple.iBooksX" } private func worldOfWarcraft(_ runningApp: NSRunningApplication, _ role: String?) -> Bool {