nocapture

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

nocapture

Keeps a window's content out of screenshots, screen recordings and screen sharing: captures show the window as a black rectangle while the user keeps seeing it normally — the way DRM-locked video players appear in a shared screen.

err := nocapture.Protect(w.Window()) // e.g. a glaze WebView handle
Platform Backend Effect
Windows SetWindowDisplayAffinity(WDA_MONITOR) window blacked out in captures
macOS — ErrUnsupported (see below)
Linux — ErrUnsupported: no portable compositor API

Why no macOS backend. The old -[NSWindow setSharingType: NSWindowSharingNone] stopped working in macOS 15.4 — ScreenCaptureKit ignores it — Apple now documents the constant as legacy, and Apple DTS has stated there is no public API for preventing screen capture. Worse: on macOS 26 setting the legacy value can stop the window from rendering at all. A backend that either does nothing or breaks the window would be worse than an honest ErrUnsupported.

Call it from the UI thread once the window exists. The handle is the toolkit's native window pointer (HWND), exactly what glaze's WebView.Window() returns.

This is a privacy courtesy enforced by the OS compositor, not content DRM: it does nothing against a camera pointed at the display.

Documentation

Overview

Package nocapture keeps a window's content out of screenshots, screen recordings and screen sharing, cgo-free — captures show the window as a black rectangle while the user keeps seeing it normally, the way DRM-locked video players appear in a shared screen.

err := nocapture.Protect(w.Window()) // e.g. a glaze WebView handle

Platform truth, stated plainly:

  • Windows: SetWindowDisplayAffinity(WDA_MONITOR). Supported and reliable.

  • macOS: ErrUnsupported. The old -[NSWindow setSharingType: NSWindowSharingNone] stopped working in macOS 15.4 (ScreenCaptureKit ignores it), Apple documents the constant as legacy, and DTS has stated there is no public API for preventing screen capture. Worse, on macOS 26 the legacy value can stop the window from rendering at all, so this package refuses to set it.

  • Linux: ErrUnsupported. Neither X11 nor Wayland exposes a portable equivalent.

This is a privacy courtesy enforced by the OS compositor, not content DRM: it does nothing against a camera pointed at the display.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = fmt.Errorf("nocapture: not supported on this platform: %w", errors.ErrUnsupported)

ErrUnsupported is returned on a platform with no working backend: Linux has no compositor API for it, and macOS removed the one it had (see the package comment).

Functions

func Protect

func Protect(window unsafe.Pointer) error

Protect marks the window's content as capture-protected: captures and screen sharing show it blacked out. The handle is the toolkit's native window pointer — an HWND on Windows, exactly what glaze's WebView.Window() returns. Call it from the UI thread, after the window exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL