diff --git a/electron/wayland.test.ts b/electron/wayland.test.ts index 56c2c0b08..097f4e390 100644 --- a/electron/wayland.test.ts +++ b/electron/wayland.test.ts @@ -13,6 +13,7 @@ describe("Wayland startup configuration", () => { }; configureWaylandSupport(commandLine, env); expect(commandLine.appendSwitch).toHaveBeenCalledWith("ozone-platform", "wayland"); + expect(commandLine.appendSwitch).toHaveBeenCalledWith("force-device-scale-factor", "1"); expect(commandLine.appendSwitch).toHaveBeenCalledWith("disable-features", "Vulkan"); }); @@ -28,6 +29,7 @@ describe("Wayland startup configuration", () => { configureWaylandSupport(commandLine, { XDG_SESSION_TYPE: "wayland" }); expect(switches.get("ozone-platform")).toBe(platform); expect(commandLine.appendSwitch).not.toHaveBeenCalledWith("ozone-platform", expect.anything()); + expect(switches.get("force-device-scale-factor")).toBe(platform === "x11" ? undefined : "1"); // Capture still goes through PipeWire under Xwayland: X11 cannot see Wayland windows. expect(commandLine.appendSwitch).toHaveBeenCalledWith( "enable-features", @@ -35,6 +37,19 @@ describe("Wayland startup configuration", () => { ); }); + it("preserves an explicit device scale factor in a Wayland session", () => { + const commandLine = { + appendSwitch: vi.fn(), + hasSwitch: (name: string) => name === "force-device-scale-factor", + getSwitchValue: (name: string) => (name === "force-device-scale-factor" ? "1.25" : ""), + }; + configureWaylandSupport(commandLine, { XDG_SESSION_TYPE: "wayland" }); + expect(commandLine.appendSwitch).not.toHaveBeenCalledWith( + "force-device-scale-factor", + expect.anything(), + ); + }); + it("keeps the features passed on the command line (#1452)", () => { // Chromium keeps only the last value of a repeated switch. const switches = new Map([ diff --git a/electron/wayland.ts b/electron/wayland.ts index abe25e030..e98b29292 100644 --- a/electron/wayland.ts +++ b/electron/wayland.ts @@ -28,6 +28,17 @@ export function configureWaylandSupport(commandLine: CommandLine, env: Env): voi if (!commandLine.hasSwitch("ozone-platform")) { commandLine.appendSwitch("ozone-platform", "wayland"); } + /* + * Chromium's unscaled Wayland size limits can clip the HUD with GTK text scaling. + * Electron 46 alpha has the fix; OpenScreen adoption may take 3–4 months (Nov 2026). + * TODO: Once we ship the fix for crbug.com/566940916, verify on Hyprland and remove. + */ + if ( + usesWaylandBackend("linux", commandLine, env) && + !commandLine.hasSwitch("force-device-scale-factor") + ) { + commandLine.appendSwitch("force-device-scale-factor", "1"); + } // Enable WebRTCPipeWireCapturer for screen capture on Wayland appendFeatures(commandLine, "enable-features", "WaylandWindowDrag,WebRTCPipeWireCapturer"); // Chromium's Wayland Ozone backend can't use Vulkan. When it tries, the WebRTC