feedback-assistant / reports

Open collection of Apple Feedback Assistant reports
237 stars 2 forks source link

FB14920414: Add API to detect whether the screen is captured (recorded, shared, or mirrored) #546

Open sindresorhus opened 3 months ago

sindresorhus commented 3 months ago

Description

macOS needs a public API to detect if the screen is being observed (recorded, shared, or mirrored). iOS already offers this with UIScreen.isCaptured. macOS should have a similar capability to ensure consistency across platforms and improve user privacy.

I assume system notifications already use an internal API for this as they have a checkbox called "Allow notifications when mirroring or sharing the display".

Use Cases:

Proposed API:

extension NSScreen {
    var isCaptured: Bool {}
}

I looked through the private headers on macOS and found that there already is a private property for this called CGSIsScreenWatcherPresent. So the functionality seems to already exist and just needs to be exposed.

samhenrigold commented 3 weeks ago

https://developer.apple.com/documentation/swiftui/environmentvalues/isscenecaptured#

Could you tap into this? Even if it means hosting an invisible SwiftUI view?

sindresorhus commented 3 weeks ago

Not available for macOS.