Create polished demo videos without editing skills. Mac/Windows/Linux
Revert "fix(linux): route X11 capture through real sources"
webadderallc50d9e1d4e6d
diff --git a/electron/ipc/register/sourceMapping.test.ts b/electron/ipc/register/sourceMapping.test.tsdeleted file mode 100644index a4c67c16..00000000--- a/electron/ipc/register/sourceMapping.test.ts+++ /dev/null@@ -1,113 +0,0 @@-import { describe, expect, it } from "vitest";--import {- getScreenSourceIdForDisplay,- LINUX_PORTAL_SCREEN_SOURCE_ID,- shouldUseSyntheticLinuxPortalSource,-} from "./sourceMapping";--describe("getScreenSourceIdForDisplay", () => {- it("keeps the live Electron screen source when one is available", () => {- expect(- getScreenSourceIdForDisplay({- displayId: "42",- matchedSourceId: "screen:42:0",- platform: "linux",- }),- ).toBe("screen:42:0");- });-- it("routes unmatched Linux Wayland screens through the portal sentinel", () => {- expect(- getScreenSourceIdForDisplay({- displayId: "42",- env: { XDG_SESSION_TYPE: "wayland", WAYLAND_DISPLAY: "wayland-0" },- matchedSourceId: null,- platform: "linux",- }),- ).toBe(LINUX_PORTAL_SCREEN_SOURCE_ID);- });-- it("keeps unmatched Linux X11 screens on the explicit fallback id", () => {- expect(- getScreenSourceIdForDisplay({- displayId: "42",- env: { XDG_SESSION_TYPE: "x11", DISPLAY: ":0" },- matchedSourceId: null,- platform: "linux",- }),- ).toBe("screen:fallback:42");- });-- it("keeps non-Linux unmatched screens on the explicit fallback id", () => {- expect(- getScreenSourceIdForDisplay({- displayId: "42",- matchedSourceId: undefined,- platform: "win32",- }),- ).toBe("screen:fallback:42");- });-});--describe("shouldUseSyntheticLinuxPortalSource", () => {- it("keeps Wayland portal capture on the synthetic source path", () => {- expect(- shouldUseSyntheticLinuxPortalSource({- env: { XDG_SESSION_TYPE: "wayland", WAYLAND_DISPLAY: "wayland-0" },- platform: "linux",- sourceId: LINUX_PORTAL_SCREEN_SOURCE_ID,- }),- ).toBe(true);- });-- it("lets X11 use Electron desktopCapturer sources instead of a synthetic id", () => {- expect(- shouldUseSyntheticLinuxPortalSource({- env: { XDG_SESSION_TYPE: "x11", DISPLAY: ":0" },- platform: "linux",- sourceId: LINUX_PORTAL_SCREEN_SOURCE_ID,- }),- ).toBe(false);- });-- it("recovers stale fallback ids through the synthetic path on Wayland", () => {- expect(- shouldUseSyntheticLinuxPortalSource({- env: { WAYLAND_DISPLAY: "wayland-0" },- platform: "linux",- sourceId: "screen:fallback:0",- }),- ).toBe(true);- });-- it("defaults unknown Linux sessions with WAYLAND_DISPLAY to the synthetic path", () => {- expect(- shouldUseSyntheticLinuxPortalSource({- env: { WAYLAND_DISPLAY: "wayland-0" },- platform: "linux",- sourceId: null,- }),- ).toBe(true);- });-- it("does not synthesize for concrete source ids", () => {- expect(- shouldUseSyntheticLinuxPortalSource({- env: { XDG_SESSION_TYPE: "wayland", WAYLAND_DISPLAY: "wayland-0" },- platform: "linux",- sourceId: "screen:42:0",- }),- ).toBe(false);- });-- it("does not synthesize outside Linux", () => {- expect(- shouldUseSyntheticLinuxPortalSource({- env: { XDG_SESSION_TYPE: "wayland", WAYLAND_DISPLAY: "wayland-0" },- platform: "win32",- sourceId: LINUX_PORTAL_SCREEN_SOURCE_ID,- }),- ).toBe(false);- });-});diff --git a/electron/ipc/register/sourceMapping.ts b/electron/ipc/register/sourceMapping.tsdeleted file mode 100644index b6a4366d..00000000--- a/electron/ipc/register/sourceMapping.ts+++ /dev/null@@ -1,59 +0,0 @@-export const LINUX_PORTAL_SCREEN_SOURCE_ID = "screen:linux-portal";--export function isLikelyLinuxWaylandSession(env: NodeJS.ProcessEnv) {- const sessionType = env.XDG_SESSION_TYPE?.trim().toLowerCase();- if (sessionType === "wayland") {- return true;- }- if (sessionType === "x11") {- return false;- }-- return Boolean(env.WAYLAND_DISPLAY);-}--export function getScreenSourceIdForDisplay({- displayId,- env = process.env,- matchedSourceId,- platform,-}: {- displayId: string;- env?: NodeJS.ProcessEnv;- matchedSourceId?: string | null;- platform: NodeJS.Platform | string;-}) {- if (matchedSourceId) {- return matchedSourceId;- }-- if (platform === "linux" && isLikelyLinuxWaylandSession(env)) {- return LINUX_PORTAL_SCREEN_SOURCE_ID;- }-- return `screen:fallback:${displayId}`;-}--export function shouldUseSyntheticLinuxPortalSource({- env,- platform,- sourceId,-}: {- env: NodeJS.ProcessEnv;- platform: NodeJS.Platform | string;- sourceId?: string | null;-}) {- if (platform !== "linux") {- return false;- }-- if (- sourceId &&- sourceId !== LINUX_PORTAL_SCREEN_SOURCE_ID &&- !sourceId.startsWith("screen:fallback:")- ) {- return false;- }-- return isLikelyLinuxWaylandSession(env);-}diff --git a/electron/ipc/register/sources.ts b/electron/ipc/register/sources.tsindex b59d9ead..4ba6b35a 100644--- a/electron/ipc/register/sources.ts+++ b/electron/ipc/register/sources.ts@@ -1,20 +1,19 @@import { execFile } from "node:child_process";import { promisify } from "node:util";import { app, BrowserWindow, desktopCapturer, ipcMain } from "electron";-import { reassertHudOverlayMousePassthrough } from "../../windows";import { ALLOW_RECORDLY_WINDOW_CAPTURE } from "../constants";+import { selectedSource, setSelectedSource } from "../state";+import type { SelectedSource } from "../types";+import { getScreen, parseWindowId } from "../utils";+import { getDisplayBoundsForSource, getDisplayWorkAreaForSource } from "../recording/ffmpeg";import {getNativeMacWindowSources,- resolveLinuxWindowBounds,resolveMacWindowBounds,resolveWindowsWindowBounds,+ resolveLinuxWindowBounds,stopWindowBoundsCapture,} from "../cursor/bounds";-import { getDisplayBoundsForSource, getDisplayWorkAreaForSource } from "../recording/ffmpeg";-import { selectedSource, setSelectedSource } from "../state";-import type { SelectedSource } from "../types";-import { getScreen, parseWindowId } from "../utils";-import { getScreenSourceIdForDisplay } from "./sourceMapping";+import { reassertHudOverlayMousePassthrough } from "../../windows";const execFileAsync = promisify(execFile);const SOURCE_LIST_CACHE_TTL_MS = 1200;@@ -126,12 +125,7 @@ export function registerSourceHandlers({: `Screen ${index + 1}`;return {- id: getScreenSourceIdForDisplay({- displayId,- env: process.env,- matchedSourceId: matchedSource?.id,- platform: process.platform,- }),+ id: matchedSource?.id ?? `screen:fallback:${displayId}`,name: displayName,originalName: matchedSource?.name ?? displayName,display_id: displayId,diff --git a/electron/main.ts b/electron/main.tsindex 68829e43..ed05ffeb 100644--- a/electron/main.ts+++ b/electron/main.ts@@ -25,7 +25,6 @@ import {killWindowsCaptureProcess,registerIpcHandlers,} from "./ipc/handlers";-import { shouldUseSyntheticLinuxPortalSource } from "./ipc/register/sourceMapping";import { ensureMediaServer } from "./mediaServer";import { ensurePackagedRendererServer } from "./rendererServer";import type { UpdateToastPayload } from "./updater";@@ -232,7 +231,7 @@ function showHudOverlayFromTray() {if (process.platform === "win32" && isHudOverlayMousePassthroughSupported()) {hud.showInactive();hud.moveTop();- reassertHudOverlayMouseState({ interactiveGraceMs: 1200 });+ reassertHudOverlayMouseState();return true;}@@ -1015,18 +1014,12 @@ app.whenReady().then(async () => {// is set we skip getSources entirely and hand back a synthetic// source id; Chromium then opens the portal once to actually// resolve the capture.- // Default to the sentinel on Linux/Wayland when no source has been+ // Default to the sentinel on Linux when no source has been// pre-selected (e.g. fresh session where the renderer skipped the// source picker entirely). This avoids calling getSources() which// would itself trigger an extra portal dialog.- // X11 does not need this synthetic path; use Electron's documented- // desktopCapturer source flow there so getDisplayMedia receives a- // real source id instead of a Wayland-only portal sentinel.- const isLinuxPortalSentinel = shouldUseSyntheticLinuxPortalSource({- env: process.env,- platform: process.platform,- sourceId,- });+ const isLinuxPortalSentinel =+ process.platform === "linux" && (sourceId === "screen:linux-portal" || !sourceId);if (isLinuxPortalSentinel) {callback({ video: { id: "screen:0:0", name: "Entire screen" } });return;diff --git a/electron/windows.ts b/electron/windows.tsindex 6173fc03..811f43c5 100644--- a/electron/windows.ts+++ b/electron/windows.ts@@ -642,11 +642,7 @@ export function getHudOverlayWindow(): BrowserWindow | null {* hover detection on the HUD is immediately restored without requiring the* user to move their mouse over the bar.*/-export function reassertHudOverlayMousePassthrough({- interactiveGraceMs = 50,-}: {- interactiveGraceMs?: number;-} = {}): void {+export function reassertHudOverlayMousePassthrough(): void {if (process.platform !== "win32" || !isHudOverlayMousePassthroughSupported()) {return;}@@ -672,7 +668,7 @@ export function reassertHudOverlayMousePassthrough({if (!hud.isDestroyed()) {setHudOverlayMousePassthrough(hudOverlayIgnoringMouse);}- }, interactiveGraceMs);+ }, 50);}export function setHudOverlayRecordingActive(recording: boolean): void {diff --git a/src/components/launch/hooks/useLaunchHudInteractionState.ts b/src/components/launch/hooks/useLaunchHudInteractionState.tsindex d7c086b1..9d0160a7 100644--- a/src/components/launch/hooks/useLaunchHudInteractionState.ts+++ b/src/components/launch/hooks/useLaunchHudInteractionState.ts@@ -13,23 +13,6 @@ export function useLaunchHudInteractionState({}) {const isMouseOverHudRef = useRef(false);const timeoutRef = useRef<NodeJS.Timeout | null>(null);- const lastInteractiveReassertAtRef = useRef(0);-- const setHudMouseInteractive = useCallback((force = false) => {- const now = performance.now();- if (- !force &&- isMouseOverHudRef.current &&- now - lastInteractiveReassertAtRef.current < 250- ) {- return;- }-- isMouseOverHudRef.current = true;- lastInteractiveReassertAtRef.current = now;- if (timeoutRef.current) clearTimeout(timeoutRef.current);- window.electronAPI?.hudOverlaySetIgnoreMouse?.(false);- }, []);useEffect(() => {if (openId !== null) {@@ -45,7 +28,7 @@ export function useLaunchHudInteractionState({}, [openId]);useEffect(() => {- const handleMouseTracking = (e: globalThis.MouseEvent) => {+ const handleMouseOver = (e: globalThis.MouseEvent) => {const target = e.target as HTMLElement | null;if (!target) return;const isInteractive = !!target.closest(@@ -53,7 +36,9 @@ export function useLaunchHudInteractionState({);if (isInteractive) {- setHudMouseInteractive();+ isMouseOverHudRef.current = true;+ if (timeoutRef.current) clearTimeout(timeoutRef.current);+ window.electronAPI?.hudOverlaySetIgnoreMouse?.(false);} else {isMouseOverHudRef.current = false;if (timeoutRef.current) clearTimeout(timeoutRef.current);@@ -70,26 +55,20 @@ export function useLaunchHudInteractionState({}};- window.addEventListener("mouseover", handleMouseTracking);- window.addEventListener("mousemove", handleMouseTracking);- return () => {- window.removeEventListener("mouseover", handleMouseTracking);- window.removeEventListener("mousemove", handleMouseTracking);- };- }, [- isHudDraggingRef,- isWebcamPreviewDraggingRef,- setHudMouseInteractive,- webcamPreviewDragStartRef,- ]);+ window.addEventListener("mouseover", handleMouseOver);+ return () => window.removeEventListener("mouseover", handleMouseOver);+ }, [isHudDraggingRef, isWebcamPreviewDraggingRef, webcamPreviewDragStartRef]);const beginInteractiveHudAction = useCallback(() => {- setHudMouseInteractive(true);- }, [setHudMouseInteractive]);+ isMouseOverHudRef.current = true;+ window.electronAPI?.hudOverlaySetIgnoreMouse?.(false);+ }, []);const handleHudMouseEnter = useCallback(() => {- setHudMouseInteractive(true);- }, [setHudMouseInteractive]);+ isMouseOverHudRef.current = true;+ if (timeoutRef.current) clearTimeout(timeoutRef.current);+ window.electronAPI?.hudOverlaySetIgnoreMouse?.(false);+ }, []);const handleHudMouseLeave = useCallback((event: MouseEvent<HTMLDivElement>) => {diff --git a/src/hooks/useScreenRecorder.test.ts b/src/hooks/useScreenRecorder.test.tsindex ed16b6a5..509b049b 100644--- a/src/hooks/useScreenRecorder.test.ts+++ b/src/hooks/useScreenRecorder.test.ts@@ -7,8 +7,6 @@ import {normalizeBrowserMicrophoneProfile,resolveBrowserCaptureCursorPolicy,resolveLinuxPortalCursorPresentation,- shouldLockHudDuringDisplaySelection,- shouldUseLinuxPortalCapture,shouldUseNativeWindowsCaptureForSource,} from "./useScreenRecorder";@@ -209,70 +207,6 @@ describe("resolveLinuxPortalCursorPresentation", () => {});});-describe("shouldUseLinuxPortalCapture", () => {- it("uses the portal when the selected source is the Linux sentinel", () => {- expect(- shouldUseLinuxPortalCapture({- browserCaptureSourceId: "screen:linux-portal",- selectedSourceId: "screen:linux-portal",- }),- ).toBe(true);- });-- it("uses the portal when a stale screen fallback resolves to the Linux sentinel", () => {- expect(- shouldUseLinuxPortalCapture({- browserCaptureSourceId: "screen:linux-portal",- selectedSourceId: "screen:fallback:42",- }),- ).toBe(true);- });-- it("keeps live Electron screen sources on browser getUserMedia", () => {- expect(- shouldUseLinuxPortalCapture({- browserCaptureSourceId: "screen:42:0",- selectedSourceId: "screen:42:0",- }),- ).toBe(false);- });-- it("prefers a live Electron source over stale portal selection state", () => {- expect(- shouldUseLinuxPortalCapture({- browserCaptureSourceId: "screen:42:0",- selectedSourceId: "screen:linux-portal",- }),- ).toBe(false);- });-});--describe("shouldLockHudDuringDisplaySelection", () => {- it("locks HUD fallback resizing while Linux portal selection is active", () => {- expect(- shouldLockHudDuringDisplaySelection({- platform: "linux",- useLinuxPortal: true,- }),- ).toBe(true);- });-- it("keeps non-portal capture flows interactive", () => {- expect(- shouldLockHudDuringDisplaySelection({- platform: "linux",- useLinuxPortal: false,- }),- ).toBe(false);- expect(- shouldLockHudDuringDisplaySelection({- platform: "win32",- useLinuxPortal: true,- }),- ).toBe(false);- });-});-describe("getScreenCaptureCursorSetting", () => {it("normalizes only supported screen-capture cursor settings", () => {expect(getScreenCaptureCursorSetting({ cursor: "motion" } as MediaTrackSettings)).toBe(diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.tsindex bb1f4e3d..9be2ff4f 100644--- a/src/hooks/useScreenRecorder.ts+++ b/src/hooks/useScreenRecorder.ts@@ -128,33 +128,6 @@ type DesktopCaptureMediaDevices = {getDisplayMedia: (constraints: unknown) => Promise<MediaStream>;};-export function shouldUseLinuxPortalCapture({- browserCaptureSourceId,- selectedSourceId,-}: {- browserCaptureSourceId?: string;- selectedSourceId?: string;-}) {- if (browserCaptureSourceId && browserCaptureSourceId !== LINUX_PORTAL_SOURCE.id) {- return false;- }-- return (- selectedSourceId === LINUX_PORTAL_SOURCE.id ||- browserCaptureSourceId === LINUX_PORTAL_SOURCE.id- );-}--export function shouldLockHudDuringDisplaySelection({- platform,- useLinuxPortal,-}: {- platform?: string;- useLinuxPortal: boolean;-}) {- return platform === "linux" && useLinuxPortal;-}-type UseScreenRecorderReturn = {recording: boolean;paused: boolean;@@ -711,7 +684,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {// on Wayland that triggers an additional xdg-desktop-portal dialog.// The sentinel is handled later by routing through getDisplayMedia,// which lets the portal pick the source in a single dialog.- if (source.id === LINUX_PORTAL_SOURCE.id) {+ if (source.id === "screen:linux-portal") {return source;}@@ -1467,7 +1440,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {// Persist the synthetic Linux portal sentinel to main so that the// setDisplayMediaRequestHandler can short-circuit getSources() and// avoid triggering an extra portal dialog.- if (!existingSource && selectedSource.id === LINUX_PORTAL_SOURCE.id) {+ if (!existingSource && selectedSource.id === "screen:linux-portal") {try {await window.electronAPI.selectSource(selectedSource);} catch (err) {@@ -1699,13 +1672,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {let videoTrack: MediaStreamTrack | undefined;let systemAudioIncluded = false;const mediaDevices = navigator.mediaDevices as DesktopCaptureMediaDevices;- const useLinuxPortal = shouldUseLinuxPortalCapture({- browserCaptureSourceId: browserCaptureSource.id,- selectedSourceId: selectedSource.id,- });- if (shouldLockHudDuringDisplaySelection({ platform, useLinuxPortal })) {- setHudSourceSelectionActive(true);- }+ const useLinuxPortal = selectedSource.id === "screen:linux-portal";const browserScreenVideoConstraints = {mandatory: {chromeMediaSource: CHROME_MEDIA_SOURCE,