fix finder cg-only window enumeration
| | |
| | | <key>CFBundlePackageType</key> |
| | | <string>APPL</string> |
| | | <key>CFBundleShortVersionString</key> |
| | | <string>0.0.23</string> |
| | | <string>0.0.24</string> |
| | | <key>CFBundleVersion</key> |
| | | <string>20260604.1723</string> |
| | | <string>20260604.1736</string> |
| | | <key>LSMinimumSystemVersion</key> |
| | | <string>26.0</string> |
| | | <key>NSHighResolutionCapable</key> |
| | |
| | | && rawBounds.height > WindowEnumerationPolicy.minimumVisibleHeight |
| | | } |
| | | |
| | | if app.bundleIdentifier == "com.apple.finder" { |
| | | return layer == 0 |
| | | && alpha > 0 |
| | | && !trimmedTitle.isEmpty |
| | | && rawBounds.width > WindowEnumerationPolicy.minimumVisibleWidth |
| | | && rawBounds.height > WindowEnumerationPolicy.minimumVisibleHeight |
| | | } |
| | | |
| | | guard app.bundleIdentifier == "io.dcloud.HBuilderX" else { return false } |
| | | |
| | | return layer == 0 |
| | |
| | | let trimmedTitle = record.title.trimmingCharacters(in: .whitespacesAndNewlines) |
| | | |
| | | switch record.app.bundleIdentifier { |
| | | case "com.apple.finder": |
| | | return !trimmedTitle.isEmpty && isLargeEnough(record.size) |
| | | case "cc.ffitch.shottr": |
| | | return trimmedTitle == "Shottr" && isLargeEnough(record.size) |
| | | case "io.dcloud.HBuilderX": |
| | |
| | | XCTAssertNil(WindowEnumerationPolicy.window(from: utilityRecord)) |
| | | } |
| | | |
| | | func testWindowEnumerationPolicyKeepsFinderCGOnlyOffscreenMainWindows() { |
| | | let finderApp = AlignerApp( |
| | | bundleIdentifier: "com.apple.finder", |
| | | name: "访达", |
| | | category: .finder |
| | | ) |
| | | let record = WindowEnumerationRecord( |
| | | id: 83_664, |
| | | app: finderApp, |
| | | title: "Screencapture", |
| | | size: CGSize(width: 920, height: 436), |
| | | subrole: .standard, |
| | | hasAXBacking: false, |
| | | isOnscreen: false |
| | | ) |
| | | let emptyTitleRecord = WindowEnumerationRecord( |
| | | id: 83_665, |
| | | app: finderApp, |
| | | title: "", |
| | | size: CGSize(width: 920, height: 436), |
| | | subrole: .standard, |
| | | hasAXBacking: false, |
| | | isOnscreen: false |
| | | ) |
| | | let tinyRecord = WindowEnumerationRecord( |
| | | id: 83_666, |
| | | app: finderApp, |
| | | title: "Finder Utility", |
| | | size: CGSize(width: 80, height: 40), |
| | | subrole: .standard, |
| | | hasAXBacking: false, |
| | | isOnscreen: false |
| | | ) |
| | | |
| | | XCTAssertEqual(WindowEnumerationPolicy.window(from: record)?.title, "Screencapture") |
| | | XCTAssertNil(WindowEnumerationPolicy.window(from: emptyTitleRecord)) |
| | | XCTAssertNil(WindowEnumerationPolicy.window(from: tinyRecord)) |
| | | } |
| | | |
| | | func testWindowEnumerationPolicyKeepsMinimizedAndFullscreenCGOnlyOffscreenWindows() { |
| | | let minimized = makeWindowRecord( |
| | | title: "Minimized Document.md", |