Skip to content
Open
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
11 changes: 10 additions & 1 deletion Clawd/ScreenContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ class ScreenContext {
}

static var hasPermission: Bool {
CGPreflightScreenCaptureAccess()
if CGPreflightScreenCaptureAccess() { return true }
// CGPreflightScreenCaptureAccess returns false on macOS 26 even when
// permission is granted. Fall back to attempting a 1x1 capture.
return CGWindowListCreateImage(
CGRect(x: 0, y: 0, width: 1, height: 1),
.optionOnScreenOnly, kCGNullWindowID, []
) != nil
}

static func requestPermission() {
Expand Down Expand Up @@ -62,7 +68,10 @@ class ScreenContext {
guard let wid = info[numKey] as? CGWindowID, !ownWindowIDs.contains(wid) else { return nil }
return wid
}
// CGImage(windowListFromArrayScreenBounds:) returns nil on macOS 26.
// Fall back to CGWindowListCreateImage which still works.
cgImage = CGImage(windowListFromArrayScreenBounds: CGRect.null, windowArray: filtered as CFArray, imageOption: .bestResolution)
?? CGWindowListCreateImage(.null, .optionOnScreenOnly, kCGNullWindowID, [.bestResolution])
} else {
cgImage = CGWindowListCreateImage(
CGRect.null,
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let package = Package(
],
swiftSettings: [
.unsafeFlags(["-parse-as-library"]),
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"]),
],
linkerSettings: [
.unsafeFlags(["-Xlinker", "-sectcreate", "-Xlinker", "__TEXT", "-Xlinker", "__info_plist", "-Xlinker", "Clawd/Info.plist"]),
Expand Down