From a4722c486da755d0e92170f0b7c34e6a1951d892 Mon Sep 17 00:00:00 2001 From: xauravww Date: Wed, 16 Sep 2026 14:04:48 +0530 Subject: [PATCH] fix(hud): expand non-passthrough HUD overlay while interactive On Linux the HUD overlay falls back to a compact bottom-centered window because mouse passthrough is unavailable. The expansion that grows the window for HUD popovers was guarded by `process.platform !== "linux"`, so it never ran on the only platform that needs it, and dropdown menus (camera, microphone, language, timer) rendered clipped behind the bar. Move the interaction -> expansion mapping into hudOverlayBounds and drop the inverted platform guard so the window expands while interactive and compacts again when click-through is restored. Fixes #944 --- electron/hudOverlayBounds.test.ts | 16 ++++++++++++++++ electron/hudOverlayBounds.ts | 19 +++++++++++++++++++ electron/windows.ts | 11 +++++++---- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/electron/hudOverlayBounds.test.ts b/electron/hudOverlayBounds.test.ts index db21e92bd..03b15ce7e 100644 --- a/electron/hudOverlayBounds.test.ts +++ b/electron/hudOverlayBounds.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { + getHudOverlayFallbackExpansionForInteraction, getHudOverlayWindowBounds, resizeHudOverlayFallbackBounds, shouldExpandHudOverlayFallback, @@ -186,3 +187,18 @@ describe("shouldExpandHudOverlayFallback", () => { ).toBe(false); }); }); + +describe("getHudOverlayFallbackExpansionForInteraction", () => { + it("expands the fallback while the HUD is interactive without mouse passthrough", () => { + expect(getHudOverlayFallbackExpansionForInteraction(false, false)).toBe(true); + }); + + it("requests compact bounds once the HUD becomes click-through", () => { + expect(getHudOverlayFallbackExpansionForInteraction(false, true)).toBe(false); + }); + + it("does not resize the window when mouse passthrough is supported", () => { + expect(getHudOverlayFallbackExpansionForInteraction(true, false)).toBeNull(); + expect(getHudOverlayFallbackExpansionForInteraction(true, true)).toBeNull(); + }); +}); diff --git a/electron/hudOverlayBounds.ts b/electron/hudOverlayBounds.ts index 8c51b88c7..877a60db4 100644 --- a/electron/hudOverlayBounds.ts +++ b/electron/hudOverlayBounds.ts @@ -50,6 +50,25 @@ export function shouldExpandHudOverlayFallback({ return fallbackExpanded || (recordingActive && webcamPreviewVisible); } +/** + * On platforms without mouse passthrough the HUD overlay is a compact fallback + * window that must grow while it is interactive, otherwise popovers such as the + * camera, source and microphone menus are clipped by the window bounds. + * + * Returns the fallback expansion to apply, or `null` when the platform uses + * real mouse passthrough and the window therefore never needs to resize. + */ +export function getHudOverlayFallbackExpansionForInteraction( + mousePassthroughSupported: boolean, + ignoreMouse: boolean, +): boolean | null { + if (mousePassthroughSupported) { + return null; + } + + return !ignoreMouse; +} + export function resizeHudOverlayFallbackBounds( workArea: HudOverlayWorkArea, currentBounds: HudOverlayWorkArea, diff --git a/electron/windows.ts b/electron/windows.ts index 23e874fa1..fb6841898 100644 --- a/electron/windows.ts +++ b/electron/windows.ts @@ -6,6 +6,7 @@ import { app, BrowserWindow, ipcMain } from "electron"; import { supportsHudCaptureProtection } from "../src/lib/hudCaptureProtection"; import { USER_DATA_PATH } from "./appPaths"; import { + getHudOverlayFallbackExpansionForInteraction, getHudOverlayWindowBounds, resizeHudOverlayFallbackBounds, shouldExpandHudOverlayFallback, @@ -311,10 +312,12 @@ function setHudOverlayMousePassthrough(ignore: boolean) { applyHudOverlayBounds(); } - if (!isHudOverlayMousePassthroughSupported()) { - if (process.platform !== "linux") { - setHudOverlayFallbackExpanded(!ignore); - } + const fallbackExpansion = getHudOverlayFallbackExpansionForInteraction( + isHudOverlayMousePassthroughSupported(), + ignore, + ); + if (fallbackExpansion !== null) { + setHudOverlayFallbackExpanded(fallbackExpansion); hudOverlayWindow.setIgnoreMouseEvents(false); return; }