Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

refactor(macos): address review — drop captureBounds validator and ready-event field

giulio3331790ccb35c87
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index dbbc936e4..85d154881 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -424,34 +424,9 @@ let nativeMacCursorRecordingStartMs = 0;
let nativeMacPauseStartedAtMs: number | null = null;
let nativeMacPauseRanges: Array<{ startMs: number; endMs: number }> = [];
let nativeMacIsPaused = false;
-// Global frame (DIP, top-left origin) of the region captured by the SCK helper. For
-// window captures this is the window's bounds, which differ from the display bounds;
-// the cursor sampler must normalize against it to avoid a fixed offset in the export.
+// Global frame of the region captured by the SCK helper (see getSelectedSourceBounds).
let activeMacCaptureBounds: Rectangle | null = null;
-function parseCaptureBounds(value: unknown): Rectangle | null {
- if (!value || typeof value !== "object") {
- return null;
- }
- const candidate = value as Partial<Rectangle>;
- if (
- typeof candidate.x === "number" &&
- typeof candidate.y === "number" &&
- typeof candidate.width === "number" &&
- typeof candidate.height === "number" &&
- candidate.width > 0 &&
- candidate.height > 0
- ) {
- return {
- x: candidate.x,
- y: candidate.y,
- width: candidate.width,
- height: candidate.height,
- };
- }
- return null;
-}
-
function normalizeCursorSample(sample: unknown): CursorRecordingSample | null {
if (!sample || typeof sample !== "object") {
return null;
@@ -1075,10 +1050,8 @@ function tryParseNativeHelperEvent(line: string) {
}
function dispatchNativeMacHelperEvent(event: Record<string, unknown>) {
- // The helper reports the captured region's global frame; window captures use it to
- // normalize cursor positions instead of the full display bounds.
- const bounds = parseCaptureBounds(event.captureBounds);
- if (bounds) {
+ const bounds = event.captureBounds as Rectangle | undefined;
+ if (bounds && bounds.width > 0 && bounds.height > 0) {
activeMacCaptureBounds = bounds;
}
nativeMacCaptureEvents.emit("helper-event", event);
@@ -1862,8 +1835,6 @@ export function registerIpcHandlers(
nativeMacPauseStartedAtMs = null;
nativeMacPauseRanges = [];
nativeMacIsPaused = false;
- // Clear any stale frame from a previous recording; the helper reports the exact
- // captured window frame in its first event, which the cursor sampler then uses.
activeMacCaptureBounds = null;
const cursorStartTimeMs = Date.now();
diff --git a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/main.swift b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/main.swift
index 31933ba27..9525b717b 100644
--- a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/main.swift
+++ b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/main.swift
@@ -186,7 +186,6 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate {
emit([
"event": "ready",
"schemaVersion": 1,
- "captureBounds": captureBoundsPayload(),
])
try await stream.startCapture()
}
diff --git a/src/lib/nativeMacRecording.ts b/src/lib/nativeMacRecording.ts
index 84b2ce738..e5137c3de 100644
--- a/src/lib/nativeMacRecording.ts
+++ b/src/lib/nativeMacRecording.ts
@@ -51,7 +51,6 @@ export type NativeMacRecordingRequest = {
export type NativeMacHelperReadyEvent = {
event: "ready";
schemaVersion: 1;
- captureBounds?: Rectangle;
};
export type NativeMacHelperRecordingStartedEvent = {