Repository navigation
fix(recording): keep a resized window whole in macOS Focused window recordings - #3942
Open
patrickballard wants to merge 1 commit into
Open
patrickballard wants to merge 1 commit into
patrickballard wants to merge 1 commit into
Conversation
Contributor
|
@patrickballard is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
…ecordings A Focused window recording reads the window through a source rect sized once, when the recording starts. A window made bigger during the recording was cut down to that first size, losing everything to the right of and below it, and a capture restart went back to the first size too. A window-only capture now checks the window's size every 100 ms and sends the running stream a source rect of the new size, worked out as the starting crop is, and a restarted stream reads the window as it is then. Each stream records the size it reads, so the check compares the window against the stream that is running. ScreenCaptureKit scales the resized window into the unchanged frame and pins it to the top left, so the cursor is placed against the area the frame covers rather than the window alone, taking the frame's shape from the capture's own frame size. Fixes CapSoftware#3941
patrickballard
force-pushed
the
fix/focused-window-resize
branch
from
November 15, 2026 19:50
12226a5 to
c6b18af
Compare
Contributor
Author
|
@greptileai review |
This branch has not been 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.
Fixes #3941.
Rebased onto #4254 (15 Nov). #4254 stopped Focus mode trimming 8 pt off each edge of the window, and noted that whichever of the two PRs landed second needed a small merge so the resize follow uses the untrimmed size. This rebase is that merge, squashed into one commit:
current_window_cropnow reads the whole window:even_pixel_cropof its bounds, exactly asScreenCaptureConfig::initbuilds the starting crop. An untouched window therefore never triggers an update.window_frame_bounds) starts at the window's own top-left corner, matching the source rect's(0, 0)origin from fix(recording): record the whole window in macOS Focus mode #4254.trim_window_cornersand its test are gone, as on main. The threewindow_frame_boundstests moved into their own test module, and fix(recording): record the whole window in macOS Focus mode #4254's three Focus tests pass unchanged.In Focused window mode, a macOS window recording reads the window through a ScreenCaptureKit source rect that was sized once, when the recording started. A window made bigger during the recording was cut down to its starting size, and everything to the right of and below that region was lost. A capture restart also went back to the starting size.
screen_capture/macos.rs): a window-only capture checks the window's size every 100 ms withcurrent_window_crop, worked out the same way as the starting crop. When the size changes, it sends the running stream a source rect of the new size withSCStream.updateConfiguration. A capture restart reads the window as it is at that moment, and each stream records the size it reads (Capturer::source_size), so the check compares the window against the stream that is running.stream_settings, used by the first stream, a restart and these updates.scap-screencapturekit: addsCapturer::update_cfg. It returns the completion future without holding the config, which isn'tSync, so theSendfollow task can await it.cursor.rs): the cursor already followed the window's current bounds, but measured against the window alone. It is now placed against the area the frame covers (window_frame_bounds), taking the frame's shape from the capture's own frame size (CursorCaptureTarget::frame_size), so it stays on the right spot when that band appears.Screen region window recordings, display and area recordings, and Windows are unchanged.
Known limitation: while a window is actively being dragged to a new size, the cursor uses the window's live size every 16 ms, but the frame changes only when the 100 ms follow check has applied the new source rect. Mid-drag, the cursor can sit up to about one follow interval of drag movement away from where the frame shows it, typically a few percent of the window. It lines up again once the stream catches up, within about 0.1 s of the drag stopping. Placing the cursor against the stream's applied size instead would remove this; it needs the size shared from the capturer to the cursor recorder, and is a separate change.
Known limitation: the cursor beside a reshaped window. Once the window's shape differs from the frame's, a pointer just past the window's right or bottom edge, but still inside the black band, is drawn over the band. The cursor is placed against the area the frame covers, which is what puts it in the right spot over the scaled window, and the renderer clips the cursor only at the frame's edge, which includes the band. With an untouched window the frame ends at the window's edge, so the cursor disappears there, as it does on main.
Hiding it at the window's edge needs the renderer to know where the window ends, and cursor move events don't carry that: they have only
x,yand the cursor id. The recorder can't work around it. A placeholder cursor id is ignored by the Circle cursor style and by click ripples, and runs shorter than a second are rewritten. Stopping moves freezes the cursor at the edge, and pushing the position past the frame edge makes the cursor smoothing draw it sliding across the band. The fix is a follow-up once this lands: an optional field on each move recording how much of the frame the window covers, which the renderer uses to clip the cursor and click ripples.Tests (after the rebase)
cargo test -p cap-recording --libon macOS: 826 passed. That includes fix(recording): record the whole window in macOS Focus mode #4254'sfocus_reads_the_whole_window_from_its_top_left,focus_reads_as_many_pixels_as_a_screen_region_at_every_scaleandfocus_reads_a_partly_offscreen_window_from_its_top_left, the even-pixel test, and the threewindow_frame_boundstests.cargo clippy -p cap-recording -p scap-screencapturekit --all-features -- -D warnings,cargo fmt --all --check, and thecursor-poll-benchmarkexample: clean.git grep trim_window_corners WINDOW_CORNER_TRIM: nothing left.studio_recordingwithwith_window_only(true). The recorded window has a coloured strip along each edge, starts at 700x450 pt, is made bigger to 1000x520 pt 3 s in and smaller to 360x300 pt 7 s in. macOS 15.7.3, 2x display, frame 1400x956.The follow check updated the stream exactly twice, once per resize, and never while the window was untouched.
Earlier checks (before the rebase, with the corner trim)
These ran on the previous two commits, through the desktop app in a sandboxed profile. The follow logic is unchanged apart from the trim.
Complete.cargo test --bin cap-gpui: 1,824 passed. The desktop app doesn't constructCursorCaptureTarget, so this change doesn't touch it.

Confidence Score: 5/5
The PR appears safe to merge with the documented cursor limitations.Summary
Focused macOS recordings now follow window resizes while keeping a fixed frame size.
Reviews (10) · Last reviewed commit: "fix(recording): keep a resized window wh..." · Reviewed by Greptile