Skip to content

fix(recording): keep a resized window whole in macOS Focused window recordings - #3942

Open
patrickballard wants to merge 1 commit into
CapSoftware:mainfrom
patrickballard:fix/focused-window-resize
Open

patrickballard wants to merge 1 commit into
CapSoftware:mainfrom
patrickballard:fix/focused-window-resize

Conversation

@patrickballard

@patrickballard patrickballard commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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:

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.

  • Size follow (screen_capture/macos.rs): a window-only capture checks the window's size every 100 ms with current_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 with SCStream.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.
  • Shared settings: the stream settings are now built in one place, stream_settings, used by the first stream, a restart and these updates.
  • scap-screencapturekit: adds Capturer::update_cfg. It returns the completion future without holding the config, which isn't Sync, so the Send follow task can await it.
  • Frame size and placement: the frame keeps its size. ScreenCaptureKit scales the resized window into it, keeping the window's shape, and pins it to the top left. A window that changes shape therefore leaves a black band on the right or at the bottom.
  • Cursor (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, y and 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 --lib on macOS: 826 passed. That includes fix(recording): record the whole window in macOS Focus mode #4254's focus_reads_the_whole_window_from_its_top_left, focus_reads_as_many_pixels_as_a_screen_region_at_every_scale and focus_reads_a_partly_offscreen_window_from_its_top_left, the even-pixel test, and the three window_frame_bounds tests.
  • cargo clippy -p cap-recording -p scap-screencapturekit --all-features -- -D warnings, cargo fmt --all --check, and the cursor-poll-benchmark example: clean.
  • git grep trim_window_corners WINDOW_CORNER_TRIM: nothing left.
  • Real capture, the way fix(recording): record the whole window in macOS Focus mode #4254 checked it: a small local program, not committed, records through studio_recording with with_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.
Window size Strips visible Black band
Starting size, 700x450 pt all four none
Made bigger, 1000x520 pt all four 187 rows below the window (189 expected)
Made smaller, 360x300 pt all four 350 columns to its right (351 expected)

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.

  • On main at the time, a window made bigger kept only its top-left starting-size region: the right and bottom strips were missing in the recording and the export. That is still main's behaviour for a resize, since fix(recording): record the whole window in macOS Focus mode #4254 doesn't follow the window.
  • Cursor: with the pointer resting over the window, the recorded cursor positions mapped back to the same screen point at all three sizes, and the export drew the cursor over that point.
  • Capture restart: forced after the window was made bigger, by stopping the stream and sending ScreenCaptureKit's "stopped by system" error from a probe that isn't in this PR. The rebuilt stream read the bigger window and followed a later resize too. With the window reshaped during a 3 s countdown, the cursor still mapped back to whole-pixel screen points against the capture's frame.
  • Native fullscreen: the whole fullscreen window was recorded, with a black band below it because fullscreen is a wider shape; main kept only the starting-size top-left corner.
  • Display recording: a display recording with system audio was unchanged, at full resolution, about 59 fps, with status Complete.
  • cargo test --bin cap-gpui: 1,824 passed. The desktop app doesn't construct CursorCaptureTarget, so this change doesn't touch it.

RetriggerView in GreptileConfidence 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.

  • macOS Focused window recordings keep resized windows whole in the frame.
  • The cursor stays aligned with resized windows in macOS recordings.

Reviews (10) · Last reviewed commit: "fix(recording): keep a resized window wh..." · Reviewed by Greptile

@vercel

vercel Bot commented Nov 8, 2026

Copy link
Copy Markdown
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.

Comment thread crates/recording/src/cursor.rs Resolved
…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
patrickballard force-pushed the fix/focused-window-resize branch from 12226a5 to c6b18af Compare November 15, 2026 19:50
@patrickballard

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread crates/recording/src/cursor.rs Resolved

This branch has not been deployed

No deployments
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.

macOS Focused window recordings cut off a window that is made bigger while recording

1 participant