Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(hud): hide the bar instead of minimizing it on Linux
Etienne Lescote237ae49fc3c
diff --git a/electron/windows.hudHide.test.ts b/electron/windows.hudHide.test.tsnew file mode 100644index 000000000..3671c247d--- /dev/null+++ b/electron/windows.hudHide.test.ts@@ -0,0 +1,70 @@+import { afterAll, describe, expect, it, vi } from "vitest";++const electron = vi.hoisted(() => {+ class FakeWindow {+ webContents = { on: vi.fn(), send: vi.fn() };+ setContentProtection = vi.fn();+ setVisibleOnAllWorkspaces = vi.fn();+ setAlwaysOnTop = vi.fn();+ isAlwaysOnTop = () => true;+ hide = vi.fn();+ minimize = vi.fn();+ once = vi.fn();+ on = vi.fn();+ loadURL = vi.fn();+ loadFile = vi.fn();+ isDestroyed() {+ return false;+ }+ }+ const handlers = new Map<string, () => void>();+ return { FakeWindow, handlers };+});++vi.mock("electron", () => ({+ app: {},+ BrowserWindow: electron.FakeWindow,+ ipcMain: {+ on: (channel: string, handler: () => void) => electron.handlers.set(channel, handler),+ },+ screen: {+ getPrimaryDisplay: () => ({ workArea: { x: 0, y: 0, width: 1920, height: 1080 } }),+ on: vi.fn(),+ },+}));++const REAL_PLATFORM = process.platform;++afterAll(() => {+ Object.defineProperty(process, "platform", { value: REAL_PLATFORM, configurable: true });+ Reflect.deleteProperty(process, "getSystemVersion");+});++/** Opens a HUD on `platform` (windows.ts decides at import) and presses "Hide recording bar". */+async function hideHudOn(platform: NodeJS.Platform) {+ Object.defineProperty(process, "platform", { value: platform, configurable: true });+ Object.defineProperty(process, "getSystemVersion", {+ value: () => (platform === "darwin" ? "15.5.0" : "10.0.26100"),+ configurable: true,+ });+ vi.resetModules();+ electron.handlers.clear();+ const { createHudOverlayWindow } = await import("./windows");+ const win = createHudOverlayWindow() as unknown as InstanceType<typeof electron.FakeWindow>;+ electron.handlers.get("hud-overlay-hide")?.();+ return win;+}++describe("Hide recording bar", () => {+ it("hides the HUD on Linux, where a Wayland client cannot un-minimize itself", async () => {+ const win = await hideHudOn("linux");+ expect(win.hide).toHaveBeenCalledOnce();+ expect(win.minimize).not.toHaveBeenCalled();+ });++ it.each(["win32", "darwin"] as const)("still minimizes the HUD on %s", async (platform) => {+ const win = await hideHudOn(platform);+ expect(win.minimize).toHaveBeenCalledOnce();+ expect(win.hide).not.toHaveBeenCalled();+ });+});diff --git a/electron/windows.ts b/electron/windows.tsindex e972caf2a..013a1f32d 100644--- a/electron/windows.ts+++ b/electron/windows.ts@@ -234,9 +234,24 @@ function watchHudWorkAreaChanges() {screen.on("display-removed", reclampHud);}+// Linux hides the bar instead of minimizing it, because a Wayland client cannot bring a+// minimized window back. xdg-shell has set_minimized and no request to undo it, and+// Chromium's Wayland Show() returns early on a toplevel that still exists, so the tray's+// restore() and show() did nothing; focus() then asked for activation without a fresh token,+// which GNOME turns into an "is ready" notification while the bar stays minimized. hide()+// destroys the toplevel and show() maps a new one, which every compositor displays. The cost+// is the position: the compositor places the new toplevel itself. X11 takes the same path:+// there `skipTaskbar` already left a minimized HUD no taskbar entry, so the tray was its only+// way back anyway.+const HUD_HIDES_INSTEAD_OF_MINIMIZING = process.platform === "linux";+ipcMain.on("hud-overlay-hide", () => {if (hudOverlayWindow && !hudOverlayWindow.isDestroyed()) {- hudOverlayWindow.minimize();+ if (HUD_HIDES_INSTEAD_OF_MINIMIZING) {+ hudOverlayWindow.hide();+ } else {+ hudOverlayWindow.minimize();+ }}});