Skip to content

Commit

Permalink
fix: don't show empty color-slurp windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharee authored and lwouis committed Jun 25, 2023
1 parent fd2f14a commit 01b3a42
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/api-wrappers/AXUIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ extension AXUIElement {
sanGuoShaAirWD(runningApp) ||
dvdFab(runningApp) ||
drBetotte(runningApp) ||
androidEmulator(runningApp, title) ||
colorSlurp(runningApp)
androidEmulator(runningApp, title)
) &&
mustHaveIfJetbrainApp(runningApp, title, subrole, size!) &&
mustHaveIfSteam(runningApp, title, role)
mustHaveIfSteam(runningApp, title, role) &&
mustHaveIfColorSlurp(runningApp, title, subrole)
))
}

Expand All @@ -117,6 +117,10 @@ extension AXUIElement {
)
}

private static func mustHaveIfColorSlurp(_ runningApp: NSRunningApplication, _ title: String?, _ subrole: String?) -> Bool {
return runningApp.bundleIdentifier != "com.IdeaPunch.ColorSlurp" || subrole == kAXStandardWindowSubrole
}

private static func iina(_ runningApp: NSRunningApplication) -> Bool {
// IINA.app can have videos float (level == 2 instead of 0)
// there is also complex animations during which we may or may not consider the window not a window
Expand Down Expand Up @@ -201,11 +205,6 @@ extension AXUIElement {
return title != "" && Applications.isAndroidEmulator(runningApp)
}

private static func colorSlurp(_ runningApp: NSRunningApplication) -> Bool {
// ColorSlurp presents its dialog as a kAXSystemDialogSubrole, so we need a special check
return runningApp.bundleIdentifier == "com.IdeaPunch.ColorSlurp"
}

func position() throws -> CGPoint? {
return try value(kAXPositionAttribute, CGPoint.zero, .cgPoint)
}
Expand Down

0 comments on commit 01b3a42

Please sign in to comment.