Repository navigation
fix(recording): record the whole window in macOS Focus mode - #4254
Open
richiemcilroy wants to merge 2 commits into
Open
richiemcilroy wants to merge 2 commits into
richiemcilroy wants to merge 2 commits into
Conversation
richiemcilroy
marked this pull request as ready for review
November 14, 2026 06:02
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · Review details |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Users on 0.6.2 and 0.6.3 (macOS 27, Apple Silicon) reported that a window recorded with Focus mode on is missing its outer edge: in a terminal, the first character of every line is gone. The same window recorded with Focus mode off is complete. "Center on screen" and the aspect ratio presets make no difference.
Root cause
Focus mode records the window by itself through a ScreenCaptureKit desktop-independent window filter. ScreenCaptureKit hands that window over with its rounded corners transparent, and the encoder turns them black. To hide those corners, c0b11f5 (in #3452) made window-only capture read the window 8 pt in from every edge (
WINDOW_CORNER_TRIM). That is 8 px on a 1x display and 16 px on Retina, taken off all four sides, which is a full terminal column on the left and right. The cursor crop was trimmed the same way, so it stayed aligned with the cut picture.Nothing else in the path changes the window's bounds. The crop comes from the window's
kCGWindowBoundsframe (no shadow), andeven_pixel_croponly drops a final odd pixel, the same as a screen-region recording.Change
source_rectreads a window-only capture from the window's own top-left corner at its full crop size.ScreenCaptureConfig::initno longer trims the window crop, so the frame size is the whole window.WINDOW_CORNER_TRIMandtrim_window_cornersare removed.macos_window_cropincursor.rsplaces the cursor against the whole window again, as it did before c0b11f5.crates/verifynow expects the window's full size instead of the size less the trim.The rounded corners of a window recorded in Focus mode are black again, as they were before c0b11f5. A screen-region recording shows whatever is behind the window there; Focus mode has nothing behind the window to show. Losing a column of the window's content is the worse of the two.
Purple badge in place of the traffic lights
This is macOS behaviour, not something Cap draws. While any ScreenCaptureKit stream names a window in its filter, macOS 27 replaces that window's traffic lights with the purple sharing badge, on screen and in the captured frames. I checked it with a standalone ScreenCaptureKit program on macOS 27.0.1, without Cap: a
desktopIndependentWindowfilter and adisplay(including: [window])filter both badge the window. A display filter that does not name the window leaves the traffic lights alone.The Tauri app never used a window filter for recording (only for one-off thumbnails), so it never showed the badge. Focus mode needs the window filter to keep windows in front of the target out of the video. #3452 tried a display crop that leaves out the windows in front, and reverted it in e1d1c1b. This PR leaves the badge as it is.
Callers checked
source_rect: the first stream (to_sources) and the restart (rebuild_capturer) inmacos.rs. Both passcaptures_windowfrom the samecapturable_windowcheck, so a window that is excluded from the recording still takes the display path with its display-relative crop.trim_window_cornerswas only called byScreenCaptureConfig::initandcursor::macos_window_crop.WINDOW_CORNER_TRIMwas only read bysource_rectand the verify test.window_only_target. Instant without a camera uses it; Instant with a camera stays on the display crop, unchanged.captures_window, so their source rect, frame size and cursor crop are unchanged. Windows and Linux do not compile any of this code.Overlap with #3942
#3942 (open) follows a window resized during a Focus recording, and computes the new source rect the same way as the starting one. Whichever lands second needs a small merge: the resize follow should use the untrimmed window size.
Tests
In
cap-recording(sources::screen_capture::macos::tests):focus_reads_the_whole_window_from_its_top_left: a Focus capture reads from (0, 0) at the full window size; the region capture of the same window keeps its display position.focus_reads_as_many_pixels_as_a_screen_region_at_every_scale: at 1x, 1.5x and 2x, with odd and half-point sizes, Focus and region read the same size and lose less than one even pixel of the window.focus_reads_a_partly_offscreen_window_from_its_top_left: a window whose crop starts off the display is still read from its own top-left corner.The trim tests are removed. The even-pixel test is kept.
cargo test -p cap-recording --lib screen_capture(30 passed) andcargo test -p cap-recording --lib cursor(29 passed) on macOS 27.0.1, Apple Silicon.Proof
Mac mini, macOS 27.0.1, Apple Silicon, one 1920x1080 display at 1x. I recorded the same Terminal window (1000x604 pt,
W<n>-first-column-markeron every line) throughstudio_recordingandinstant_recordingwithwith_window_only(false)(Focus off) andwith_window_only(true)(Focus on). The program is a 50-line local example that calls the builders the same way the app does; it is not committed. Each mode was built from main and from this branch.Pixel comparison of Focus on against Focus off, from a frame 2 s in, 4 px in from every edge:
Terminal, top-left corner at 4x. Left to right: Focus off, Focus on with main, Focus on with this PR.
Same for Instant:
Bottom-right corner, Studio. Main loses the corner and the last rows; this PR keeps them, with the rounded corner black:
Whole frames, Focus off and on with this PR: terminal-fix-focus-off-vs-on.png
Other windows, Studio, Focus on:
Finder: Focus off, main, this PR · Partly offscreen Terminal: Focus off, main, this PR
CI:
real-capture (blacksmith-6vcpu-macos-26)runsrecording/studio-window/focusthrough the full studio pipeline. On this branch it records the 640x400 stimulus window at 640x400 (154 frames), and its size check now fails on anything smaller than the whole window.Proof on a Retina display
The mini's panel has no HiDPI mode, so I added a 1280x800 pt virtual display at 2x (2560x1600 px) with CoreGraphics'
CGVirtualDisplayfor the length of the run, then removed it. macOS treats it as a real Retina display: WindowServer composites at 2x and ScreenCaptureKit captures it like any other display. The 1080p panel stayed attached at 1x, so this also covers a second display at a different scale. I recorded the same Terminal window (1000x604 pt) on the 2x display, Studio and Instant, Focus off and on, from main and from this branch.Terminal top-left corner on the 2x display, at 3x. Left to right: Focus off, Focus on with main, Focus on with this PR.
Bottom-right corner, Studio:
Not covered on hardware


Confidence Score: 5/5
The PR appears safe to merge.Summary
Restores the full window in macOS Focus recordings instead of removing 8 points from every edge.
No actionable issues found. Native macOS capture was not run in this Linux environment.
Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile