Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/DefiMacOS/AXFocusOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ struct AXFocusOperations: @unchecked Sendable {
element, kAXFocusedAttribute as CFString, &rawValue
) == .success, let rawValue, CFGetTypeID(rawValue) == CFBooleanGetTypeID()
else { return nil }
return CFBooleanGetValue(rawValue as! CFBoolean)
return CFBooleanGetValue(unsafeDowncast(rawValue, to: CFBoolean.self))
}
}
11 changes: 7 additions & 4 deletions Sources/DefiMacOS/AXFrameCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ final class AXFrameCoordinator: @unchecked Sendable {
lock.unlock()
for (processID, restore) in retiredEnhancedUIRestores {
guard let reservation = restoreReservations[processID] else { continue }
let token = restore.token
reservation.queue.async { [self, reservation] in
defer {
reservation.release()
Expand All @@ -696,17 +697,19 @@ final class AXFrameCoordinator: @unchecked Sendable {
let superseded = deferredEnhancedUIRestores[processID] != nil
lock.unlock()
guard !superseded else { return }
let restored = AXMessagingTimeoutAccess.shared.withTimeout(0.016, elements: [restore.application]) {
accessibilityWriter.setEnhancedUserInterface(true, application: restore.application)
// AXUIElement isn't Sendable; an application element is fully identified by its pid.
let application = AXUIElementCreateApplication(processID)
let restored = AXMessagingTimeoutAccess.shared.withTimeout(0.016, elements: [application]) {
accessibilityWriter.setEnhancedUserInterface(true, application: application)
}
lock.lock()
deferredEnhancedUIRestores[processID]?.disabled = false
if !restored {
// Keep a failed retirement recoverable by rediscovery or shutdown.
if deferredEnhancedUIRestores[processID] == nil {
deferredEnhancedUIRestores[processID] = (restore.token, restore.application, false)
deferredEnhancedUIRestores[processID] = (token, application, false)
}
appendTraceLocked("enhanced-ui-restore-failed pid=\(processID) token=\(restore.token) retired=1")
appendTraceLocked("enhanced-ui-restore-failed pid=\(processID) token=\(token) retired=1")
}
lock.unlock()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ extension SnapshotEngine {
let retryNow = discoveryNow
if unmatchedWindowElementsByProcess[processID]?.isEmpty == false {
if unmatchedWindowRetryIsPending(attempts: unmatchedWindowRetryAttemptsByProcess[processID] ?? 0),
processWindowRetryDeadlines[processID].map { $0 <= retryNow + 0.000001 } == true
processWindowRetryDeadlines[processID].map({ $0 <= retryNow + 0.000001 }) == true
{
consumeUnmatchedWindowRetries(processIDs: [processID])
} else if forceWindowListRefresh && !unmatchedWindowRetryIsPending(
Expand Down
2 changes: 1 addition & 1 deletion Sources/DefiMacOS/WindowSnapshotRefreshPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func appBundleIdentifier(executablePath: String) -> String? {
func appBundleIdentifier(processID: pid_t) -> String? {
var path = [CChar](repeating: 0, count: Int(MAXPATHLEN) * 4)
guard proc_pidpath(processID, &path, UInt32(path.count)) > 0 else { return nil }
return appBundleIdentifier(executablePath: String(cString: path))
return appBundleIdentifier(executablePath: String(decoding: path.prefix { $0 != 0 }.map { UInt8(bitPattern: $0) }, as: UTF8.self))
}

func resolvedFrontmostProcessID(
Expand Down
Loading