From a368af3f017ed97806d5dd798416dddb276745c8 Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Mon, 10 May 2021 16:22:53 +0900 Subject: [PATCH] fix: remove jetbrain app non-windows (closes #885) --- src/api-wrappers/AXUIElement.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api-wrappers/AXUIElement.swift b/src/api-wrappers/AXUIElement.swift index c3fe7521..67d92a68 100644 --- a/src/api-wrappers/AXUIElement.swift +++ b/src/api-wrappers/AXUIElement.swift @@ -85,6 +85,7 @@ extension AXUIElement { (books(runningApp) || keynote(runningApp) || ( // CGWindowLevel == .normalWindow helps filter out iStats Pro and other top-level pop-overs, and floating windows level == AXUIElement.normalLevel && + jetbrainApp(runningApp, title) && ([kAXStandardWindowSubrole, kAXDialogSubrole].contains(subrole) || openBoard(runningApp) || adobeAudition(runningApp, subrole) || @@ -99,6 +100,12 @@ extension AXUIElement { drBetotte(runningApp)))) } + private static func jetbrainApp(_ runningApp: NSRunningApplication, _ title: String?) -> Bool { + // jetbrain apps sometimes generate non-windows that pass all checks in isActualWindow + // they have no title, so we can filter them out based on that + return runningApp.bundleIdentifier?.range(of: "^com\\.jetbrains\\..+?$", options: .regularExpression) == nil || (title != nil && title != "") + } + private static func keynote(_ runningApp: NSRunningApplication) -> Bool { // apple Keynote has a fake fullscreen window when in presentation mode // it covers the screen with a AXUnknown window instead of using standard fullscreen mode