diff --git a/electron/recording/linuxCaptureBackend.test.ts b/electron/recording/linuxCaptureBackend.test.ts index 465fa5e71..221d24eec 100644 --- a/electron/recording/linuxCaptureBackend.test.ts +++ b/electron/recording/linuxCaptureBackend.test.ts @@ -92,6 +92,18 @@ describe("X11 source resolution", () => { y: 0, }); }); + it("records the only display when Electron's X11 display_id matches no screen id (#1629)", () => { + const laptop = [ + { id: 2_147_483_648, bounds: { x: 0, y: 0, width: 1920, height: 1080 }, scaleFactor: 1 }, + ]; + expect(resolveX11CaptureSource({ id: "screen:383:0", display_id: "2" }, laptop)).toEqual({ + kind: "display", + x: 0, + y: 0, + width: 1920, + height: 1080, + }); + }); it("rejects stale, missing and malformed sources instead of recording something else", () => { expect(() => resolveX11CaptureSource(null, displays)).toThrow(); expect(() => diff --git a/electron/recording/linuxCaptureBackend.ts b/electron/recording/linuxCaptureBackend.ts index ce0b91c39..aee71dd6d 100644 --- a/electron/recording/linuxCaptureBackend.ts +++ b/electron/recording/linuxCaptureBackend.ts @@ -92,7 +92,14 @@ export function resolveX11CaptureSource( return { kind: "window", windowId }; } if (!source.id.startsWith("screen:")) throw new Error("Unsupported X11 recording source."); - const display = displays.find((candidate) => String(candidate.id) === source.display_id); + // Electron derives desktopCapturer's X11 display_id with its own copy of Chromium's + // EDID logic, which falls back to the output index for an output id above 0xff + // (NVIDIA): it then matches no `screen` id (#1629). A single display is still the + // one picked. ponytail: several displays still need the id to match; resolving the + // RandR monitor atom of `screen::0` in the helper would cover them. + const display = + displays.find((candidate) => String(candidate.id) === source.display_id) ?? + (displays.length === 1 ? displays[0] : undefined); if (!display) throw new Error("The selected X11 display is no longer available."); const { bounds, scaleFactor } = display; if (displays.some((candidate) => candidate.scaleFactor !== scaleFactor)) {