Skip to content
Merged
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
9 changes: 8 additions & 1 deletion apps/desktop/native/computer-use/ComputerUse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,16 @@ func appFor(_ bundleId: String?, launch: Bool = false) async throws -> NSRunning
func requireAccessibility() throws {
guard AXIsProcessTrusted() else { throw ComputerError("accessibility_permission_required", "Enable Accessibility for Mothership in System Settings, then retry.") }
}
/// The app's window-list entries at document, floating and panel levels. Calendar's event inspector is a
/// panel-level window, so it must be observable; the Dock level and above (menus, status items,
/// overlays) holds no app window.
func windowsFor(_ pid: pid_t) -> [[String: Any]] {
guard let entries = CGWindowListCopyWindowInfo([.optionAll, .excludeDesktopElements], kCGNullWindowID) as? [[String: Any]] else { return [] }
return entries.filter { ($0[kCGWindowOwnerPID as String] as? NSNumber)?.int32Value == pid && ($0[kCGWindowLayer as String] as? Int) == 0 }
let dockLevel = Int(CGWindowLevelForKey(.dockWindow))
return entries.filter { entry in
guard (entry[kCGWindowOwnerPID as String] as? NSNumber)?.int32Value == pid, let layer = entry[kCGWindowLayer as String] as? Int else { return false }
return layer >= 0 && layer < dockLevel
}
}
/// Whether the app has a window an observation can list: an Accessibility window whose frame matches
/// one of its window-list entries, the match `get_app_state` uses. A minimized window counts, since it
Expand Down
Loading