Skip to content

feat:content protection#183

Open
rishaan05 wants to merge 1 commit intoblackboardsh:mainfrom
rishaan05:feat/content-protection
Open

feat:content protection#183
rishaan05 wants to merge 1 commit intoblackboardsh:mainfrom
rishaan05:feat/content-protection

Conversation

@rishaan05
Copy link

Summary

Adds a contentProtection API to BrowserWindow, allowing apps to prevent their windows from being captured via screenshots, screen recording, or screen sharing tools. Equivalent to Electron's win.setContentProtection().

New API

const win = new BrowserWindow({ contentProtection: true });

win.setContentProtection(true);
win.setContentProtection(false);

Platform Support

Platform Implementation
macOS [NSWindow setSharingType:NSWindowSharingNone]
Windows SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE) (Windows 10 v2004+)

Testing

  1. Run bun dev from the package folder
  2. Open Run Interactive Tests"Window content protection playground"
  3. Take a screenshot (Cmd+Shift+4 → Space on macOS) with protection ON. Window should not appear in image.
  4. Click Toggle Protection to turn it OFF. Window should now be visible in screenshots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant