Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion electron/electron-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ interface Window {
options?: {
preserveProjectPath?: boolean;
hideOverlayCursorByDefault?: boolean;
nativeCaptureUnavailable?: boolean;
},
) => Promise<{ success: boolean; webcamPath: string | null }>;
setCurrentRecordingSession: (
Expand All @@ -683,6 +684,7 @@ interface Window {
webcamPath?: string | null;
timeOffsetMs?: number;
hideOverlayCursorByDefault?: boolean;
nativeCaptureUnavailable?: boolean;
},
options?: { preserveProjectPath?: boolean },
) => Promise<{ success: boolean }>;
Expand All @@ -693,6 +695,7 @@ interface Window {
webcamPath?: string | null;
timeOffsetMs?: number;
hideOverlayCursorByDefault?: boolean;
nativeCaptureUnavailable?: boolean;
};
}>;
getCurrentVideoPath: () => Promise<{ success: boolean; path?: string }>;
Expand Down Expand Up @@ -838,7 +841,11 @@ interface Window {
/** Returns the app version from package.json */
getAppVersion: () => Promise<string>;
/** Hide the OS cursor before browser capture starts. */
hideOsCursor: () => Promise<{ success: boolean }>;
hideOsCursor: () => Promise<{
success: boolean;
unsupported?: boolean;
platform?: string;
}>;
/** Recording preferences (mic, system audio) */
getRecordingPreferences: () => Promise<{
success: boolean;
Expand Down
9 changes: 7 additions & 2 deletions electron/ipc/register/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ export function registerProjectHandlers() {
return { success: false, error: String(error), message: 'Failed to open projects folder.' }
}
})
ipcMain.handle('set-current-video-path', async (_, path: string, options?: { preserveProjectPath?: boolean; hideOverlayCursorByDefault?: boolean }) => {
ipcMain.handle('set-current-video-path', async (_, path: string, options?: { preserveProjectPath?: boolean; hideOverlayCursorByDefault?: boolean; nativeCaptureUnavailable?: boolean }) => {
setCurrentVideoPath(normalizeVideoSourcePath(path) ?? path)
approveUserPath(currentVideoPath)
const resolvedSession = await resolveRecordingSession(currentVideoPath)
Expand All @@ -548,6 +548,10 @@ export function registerProjectHandlers() {
hideOverlayCursorByDefault:
normalizeBoolean(options?.hideOverlayCursorByDefault) ||
normalizeBoolean(resolvedSession.hideOverlayCursorByDefault),
nativeCaptureUnavailable:
normalizeBoolean(
options?.nativeCaptureUnavailable ?? resolvedSession.nativeCaptureUnavailable,
),
}

setCurrentRecordingSession(nextSession)
Expand All @@ -573,14 +577,15 @@ export function registerProjectHandlers() {
return { success: true, webcamPath: nextSession.webcamPath ?? null }
})

ipcMain.handle('set-current-recording-session', async (_, session: { videoPath: string; webcamPath?: string | null; timeOffsetMs?: number; hideOverlayCursorByDefault?: boolean }, options?: { preserveProjectPath?: boolean }) => {
ipcMain.handle('set-current-recording-session', async (_, session: { videoPath: string; webcamPath?: string | null; timeOffsetMs?: number; hideOverlayCursorByDefault?: boolean; nativeCaptureUnavailable?: boolean }, options?: { preserveProjectPath?: boolean }) => {
const normalizedVideoPath = normalizeVideoSourcePath(session.videoPath) ?? session.videoPath
setCurrentVideoPath(normalizedVideoPath)
setCurrentRecordingSession({
videoPath: normalizedVideoPath,
webcamPath: normalizeVideoSourcePath(session.webcamPath ?? null),
timeOffsetMs: normalizeRecordingTimeOffsetMs(session.timeOffsetMs),
hideOverlayCursorByDefault: normalizeBoolean(session.hideOverlayCursorByDefault),
nativeCaptureUnavailable: normalizeBoolean(session.nativeCaptureUnavailable),
});
await rememberApprovedLocalReadPath(currentRecordingSession!.videoPath)
await rememberApprovedLocalReadPath(currentRecordingSession!.webcamPath)
Expand Down
2 changes: 1 addition & 1 deletion electron/ipc/register/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function registerSettingsHandlers() {
// ---------------------------------------------------------------------------
ipcMain.handle("hide-cursor", () => {
if (process.platform !== "win32") {
return { success: true };
return { success: false, unsupported: true, platform: process.platform };
}

return { success: hideCursor() };
Expand Down
1 change: 1 addition & 0 deletions electron/ipc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type RecordingSessionData = {
webcamPath?: string | null;
timeOffsetMs?: number;
hideOverlayCursorByDefault?: boolean;
nativeCaptureUnavailable?: boolean;
};

export type PauseSegment = {
Expand Down
2 changes: 2 additions & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ contextBridge.exposeInMainWorld("electronAPI", {
options?: {
preserveProjectPath?: boolean;
hideOverlayCursorByDefault?: boolean;
nativeCaptureUnavailable?: boolean;
},
) => {
return ipcRenderer.invoke("set-current-video-path", path, options);
Expand All @@ -697,6 +698,7 @@ contextBridge.exposeInMainWorld("electronAPI", {
webcamPath?: string | null;
timeOffsetMs?: number;
hideOverlayCursorByDefault?: boolean;
nativeCaptureUnavailable?: boolean;
},
options?: { preserveProjectPath?: boolean },
) => {
Expand Down
10 changes: 10 additions & 0 deletions src/components/video-editor/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3295,6 +3295,7 @@ export function SettingsPanel({
<Switch
checked={showCursor}
onCheckedChange={onShowCursorChange}
disabled={nativeCaptureUnavailableSession}
className="data-[state=checked]:bg-[#2563EB] scale-75"
/>
</label>
Expand All @@ -3303,11 +3304,20 @@ export function SettingsPanel({
<Switch
checked={loopCursor}
onCheckedChange={onLoopCursorChange}
disabled={nativeCaptureUnavailableSession}
className="data-[state=checked]:bg-[#2563EB] scale-75"
/>
</label>
</div>
</div>
{nativeCaptureUnavailableSession ? (
<div className="rounded-lg border border-amber-400/25 bg-amber-400/10 px-3 py-2 text-[10px] leading-4 text-muted-foreground">
{tSettings(
"effects.cursorOverlayUnavailable",
"Cursor overlay is unavailable for this recording because the captured video already contains the system cursor.",
)}
</div>
) : null}
<div className="flex flex-col gap-1.5">
<div className="space-y-1.5">
<ToggleGroup
Expand Down
16 changes: 12 additions & 4 deletions src/components/video-editor/VideoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1222,10 +1222,18 @@ export default function VideoEditor() {
setExportProgress(resolveSavingExportProgress);
}, []);

const handleShowCursorChange = useCallback((nextShowCursor: boolean) => {
setSessionShowCursorOverride(null);
setShowCursor(nextShowCursor);
}, []);
const handleShowCursorChange = useCallback(
(nextShowCursor: boolean) => {
if (nextShowCursor && sessionNativeCaptureUnavailable) {
setNativeCaptureUnavailableModalOpen(true);
return;
}

setSessionShowCursorOverride(null);
setShowCursor(nextShowCursor);
},
[sessionNativeCaptureUnavailable],
);

const remountPreview = useCallback(() => {
setIsPreviewReady(false);
Expand Down
59 changes: 59 additions & 0 deletions src/hooks/useScreenRecorder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import {
createBrowserRecordingOptions,
createProcessedMicrophoneConstraints,
getScreenCaptureCursorSetting,
normalizeBrowserMicrophoneProfile,
resolveBrowserCaptureCursorPolicy,
resolveLinuxPortalCursorPresentation,
shouldUseNativeWindowsCaptureForSource,
} from "./useScreenRecorder";

Expand Down Expand Up @@ -145,6 +147,7 @@ describe("resolveBrowserCaptureCursorPolicy", () => {
streamCursor: "never",
hideOsCursorBeforeRecording: true,
hideEditorOverlayCursorByDefault: true,
nativeCaptureUnavailable: false,
});
});

Expand All @@ -155,8 +158,64 @@ describe("resolveBrowserCaptureCursorPolicy", () => {
streamCursor: "always",
hideOsCursorBeforeRecording: false,
hideEditorOverlayCursorByDefault: true,
nativeCaptureUnavailable: true,
});
});

it("does not fake OS cursor hiding on Linux portal capture", () => {
expect(resolveBrowserCaptureCursorPolicy({ platform: "linux" })).toEqual({
streamCursor: "never",
hideOsCursorBeforeRecording: false,
hideEditorOverlayCursorByDefault: true,
nativeCaptureUnavailable: true,
});
});
});

describe("resolveLinuxPortalCursorPresentation", () => {
it("enables the Recordly overlay only when the portal confirms cursor-hidden capture", () => {
expect(
resolveLinuxPortalCursorPresentation({
requestedCursor: "never",
actualCursor: "never",
}),
).toEqual({
hideEditorOverlayCursorByDefault: false,
nativeCaptureUnavailable: false,
});
});

it("keeps the overlay disabled when the portal embeds or omits cursor settings", () => {
expect(
resolveLinuxPortalCursorPresentation({
requestedCursor: "never",
actualCursor: "always",
}),
).toEqual({
hideEditorOverlayCursorByDefault: true,
nativeCaptureUnavailable: true,
});
expect(
resolveLinuxPortalCursorPresentation({
requestedCursor: "never",
actualCursor: null,
}),
).toEqual({
hideEditorOverlayCursorByDefault: true,
nativeCaptureUnavailable: true,
});
});
});

describe("getScreenCaptureCursorSetting", () => {
it("normalizes only supported screen-capture cursor settings", () => {
expect(getScreenCaptureCursorSetting({ cursor: "motion" } as MediaTrackSettings)).toBe(
"motion",
);
expect(
getScreenCaptureCursorSetting({ cursor: "hidden" } as MediaTrackSettings),
).toBeNull();
});
});

describe("shouldUseNativeWindowsCaptureForSource", () => {
Expand Down
Loading