Skip to content

feat(wallpaper): composite window captures onto a custom background - #20

Merged
aryasadeghy merged 1 commit into
mainfrom
feat/window-background-compositor
May 9, 2026
Merged

feat(wallpaper): composite window captures onto a custom background#20
aryasadeghy merged 1 commit into
mainfrom
feat/window-background-compositor

Conversation

@aryasadeghy

Copy link
Copy Markdown
Contributor

Implements the CleanShot-style "Wallpaper" feature correctly: window captures are composited onto a chosen background image or solid color, with adjustable padding and a CSS drop-shadow that follows the window's real alpha shape (rounded corners). Area / fullscreen captures are unaffected — they already include the real desktop.

The previous attempt (now scrapped) tried to swap the actual macOS wallpaper via osascript before each capture. That's not what CleanShot does and produced the wrong visual.

Implementation:

  • New src/main/capture/compositor.ts. Spawns a hidden BrowserWindow sized to windowSize + 2 * padding, loads inline HTML that paints the bg + the window image with filter: drop-shadow(...), then uses webContents.capturePage() to extract the composite as PNG. Window image and bg image are passed as base64 data URLs so we don't have to fight CSP for file:// references.
  • takeScreenshot writes the raw window screenshot to a temp file when compositing is needed, runs the compositor, then unlinks the temp. Falls back to the raw window image on any compositor error.
  • Settings → Wallpaper now has a real panel: mode picker (System / Custom image / Solid color), padding slider, image picker, color picker.
  • Settings → General gains "Hide desktop icons while capturing" — the during-capture flavor that mirrors CleanShot's General-tab checkbox. The persistent toggle stays on the menu bar.

Tested:

  • typecheck, lint, vitest (21), prod build all green
  • the heavy lifting (BrowserWindow + capturePage) needs a runtime smoke test on macOS — manual instructions are in the PR description

Summary

Type

  • feat — new feature
  • fix — bug fix
  • docs — documentation only
  • refactor — code restructure, no behavior change
  • perf — performance improvement
  • test — adds or changes tests
  • chore / ci / build — tooling

Screenshots / recording

Test plan

  • npm run lint
  • npm run typecheck
  • npm test
  • Manual smoke: launched the app, exercised the changed feature
  • Manual smoke: nothing else regressed

Clean-room confirmation

  • I confirm this contribution is not derived from decompiled or leaked commercial software (see CONTRIBUTING.md).

Linked issues

Closes #

Implements the CleanShot-style "Wallpaper" feature correctly: window
captures are composited onto a chosen background image or solid color,
with adjustable padding and a CSS drop-shadow that follows the window's
real alpha shape (rounded corners). Area / fullscreen captures are
unaffected — they already include the real desktop.

The previous attempt (now scrapped) tried to swap the actual macOS
wallpaper via `osascript` before each capture. That's not what CleanShot
does and produced the wrong visual.

Implementation:
- New `src/main/capture/compositor.ts`. Spawns a hidden BrowserWindow
  sized to `windowSize + 2 * padding`, loads inline HTML that paints the
  bg + the window image with `filter: drop-shadow(...)`, then uses
  `webContents.capturePage()` to extract the composite as PNG. Window
  image and bg image are passed as base64 data URLs so we don't have to
  fight CSP for `file://` references.
- `takeScreenshot` writes the raw window screenshot to a temp file when
  compositing is needed, runs the compositor, then unlinks the temp.
  Falls back to the raw window image on any compositor error.
- Settings → Wallpaper now has a real panel: mode picker
  (System / Custom image / Solid color), padding slider, image picker,
  color picker.
- Settings → General gains "Hide desktop icons while capturing" — the
  during-capture flavor that mirrors CleanShot's General-tab checkbox.
  The persistent toggle stays on the menu bar.

Tested:
- typecheck, lint, vitest (21), prod build all green
- the heavy lifting (BrowserWindow + capturePage) needs a runtime
  smoke test on macOS — manual instructions are in the PR description

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aryasadeghy
aryasadeghy enabled auto-merge (squash) May 9, 2026 23:43
@aryasadeghy
aryasadeghy merged commit 3ab00a8 into main May 9, 2026
3 checks passed
@aryasadeghy
aryasadeghy deleted the feat/window-background-compositor branch May 9, 2026 23:44
// Trusted local content (our own HTML + already-validated images).
// We need this off so the data: URL renders the embedded images
// without CSP fights.
webSecurity: false,
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.

2 participants