Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions electron/hudOverlayBounds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";

import {
getHudOverlayWindowBounds,
isWaylandSession,
resizeHudOverlayFallbackBounds,
shouldExpandHudOverlayFallback,
} from "./hudOverlayBounds";
Expand Down Expand Up @@ -185,4 +186,33 @@ describe("shouldExpandHudOverlayFallback", () => {
}),
).toBe(false);
});

it("always expands on Wayland so menus fit without runtime resizing", () => {
expect(
shouldExpandHudOverlayFallback({
fallbackExpanded: false,
recordingActive: true,
webcamPreviewVisible: false,
waylandSession: true,
}),
).toBe(true);
});
});

describe("isWaylandSession", () => {
it("detects Wayland from XDG_SESSION_TYPE on Linux", () => {
expect(isWaylandSession({ XDG_SESSION_TYPE: "wayland" }, "linux")).toBe(true);
});

it("detects Wayland from WAYLAND_DISPLAY on Linux", () => {
expect(isWaylandSession({ WAYLAND_DISPLAY: "wayland-0" }, "linux")).toBe(true);
});

it("returns false for X11 sessions", () => {
expect(isWaylandSession({ XDG_SESSION_TYPE: "x11" }, "linux")).toBe(false);
});

it("returns false outside Linux", () => {
expect(isWaylandSession({ XDG_SESSION_TYPE: "wayland" }, "darwin")).toBe(false);
});
});
13 changes: 13 additions & 0 deletions electron/hudOverlayBounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,27 @@ export function shouldExpandHudOverlayFallback({
fallbackExpanded,
recordingActive,
webcamPreviewVisible,
waylandSession = false,
}: {
fallbackExpanded: boolean;
recordingActive: boolean;
webcamPreviewVisible: boolean;
waylandSession?: boolean;
}): boolean {
// Wayland ignores client-side repositioning, so resizing at runtime shifts the
// HUD away from the pointer. Keep it expanded so menus always fit.
if (waylandSession) {
return true;
}
return fallbackExpanded || (recordingActive && webcamPreviewVisible);
}

export function isWaylandSession(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): boolean {
return (
platform === "linux" && (env.XDG_SESSION_TYPE === "wayland" || Boolean(env.WAYLAND_DISPLAY))
);
}

export function resizeHudOverlayFallbackBounds(
workArea: HudOverlayWorkArea,
currentBounds: HudOverlayWorkArea,
Expand Down
2 changes: 2 additions & 0 deletions electron/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { supportsHudCaptureProtection } from "../src/lib/hudCaptureProtection";
import { USER_DATA_PATH } from "./appPaths";
import {
getHudOverlayWindowBounds,
isWaylandSession,
resizeHudOverlayFallbackBounds,
shouldExpandHudOverlayFallback,
} from "./hudOverlayBounds";
Expand Down Expand Up @@ -206,6 +207,7 @@ function getHudOverlayBounds() {
fallbackExpanded: hudOverlayFallbackExpanded,
recordingActive: hudOverlayRecordingActive,
webcamPreviewVisible: hudOverlayWebcamPreviewVisible,
waylandSession: isWaylandSession(process.env, process.platform),
});
return getHudOverlayWindowBounds(
workArea,
Expand Down