Skip to content
Merged
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
15 changes: 14 additions & 1 deletion src/components/launch/LaunchWindow.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,8 @@ type SelectedSourceChangedListener = Parameters<
Window["electronAPI"]["onSelectedSourceChanged"]
>[0];

const platformState = vi.hoisted(() => ({ value: "darwin" }));

const recorderState = vi.hoisted(() => ({
value: {
recording: false,
Expand DownExpand Up@@ -71,7 +73,7 @@ vi.mock("../../lib/requestCameraAccess", () => ({
vi.mock("@/native", () => ({
nativeBridgeClient: {
system: {
getPlatform: vi.fn(async () => "darwin"),
getPlatform: vi.fn(async () => platformState.value),
},
},
}));
Expand DownExpand Up@@ -190,6 +192,7 @@ function emitSourceSelectorClosed() {

describe("LaunchWindow record button", () => {
beforeEach(() => {
platformState.value = "darwin";
class ResizeObserver {
observe() {
return undefined;
Expand DownExpand Up@@ -327,4 +330,14 @@ describe("LaunchWindow record button", () => {
expect(recorderState.value.toggleRecording).toHaveBeenCalledTimes(1);
expect(window.electronAPI.openSourceSelector).not.toHaveBeenCalled();
});

it("keeps the HUD interactive on Linux so the drag handle can receive pointer events", async () => {
platformState.value = "linux";

renderLaunchWindow();

await waitFor(() => {
expect(window.electronAPI.setHudOverlayIgnoreMouseEvents).toHaveBeenLastCalledWith(false);
});
});
});
23 changes: 15 additions & 8 deletions src/components/launch/LaunchWindow.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -143,6 +143,7 @@ export function LaunchWindow() {
() => loadUserPreferences().trayLayout,
);
const [supportsCursorModeToggle, setSupportsCursorModeToggle] = useState(false);
const [isLinuxHud, setIsLinuxHud] = useState(false);
const languageTriggerRef = useRef<HTMLButtonElement | null>(null);
const languageMenuPanelRef = useRef<HTMLDivElement | null>(null);
const hudBarRef = useRef<HTMLDivElement | null>(null);
Expand DownExpand Up@@ -212,11 +213,13 @@ export function LaunchWindow() {
.then((platform) => {
if (!cancelled) {
setSupportsCursorModeToggle(platform === "win32" || platform === "darwin");
setIsLinuxHud(platform === "linux");
}
})
.catch(() => {
if (!cancelled) {
setSupportsCursorModeToggle(false);
setIsLinuxHud(false);
}
});

Expand DownExpand Up@@ -400,14 +403,18 @@ export function LaunchWindow() {
[observeHudElement],
);

const hudMouseEventsEnabledRef = useRef<boolean | undefined>(undefined);
const setHudMouseEventsEnabled = useCallback((enabled: boolean) => {
if (hudMouseEventsEnabledRef.current === enabled) {
return;
}
hudMouseEventsEnabledRef.current = enabled;
window.electronAPI?.setHudOverlayIgnoreMouseEvents?.(!enabled);
}, []);
const hudIgnoreMouseEventsRef = useRef<boolean | undefined>(undefined);
const setHudMouseEventsEnabled = useCallback(
(enabled: boolean) => {
const shouldIgnoreMouseEvents = !enabled && !isLinuxHud;
if (hudIgnoreMouseEventsRef.current === shouldIgnoreMouseEvents) {
return;
}
hudIgnoreMouseEventsRef.current = shouldIgnoreMouseEvents;
window.electronAPI?.setHudOverlayIgnoreMouseEvents?.(shouldIgnoreMouseEvents);
},
[isLinuxHud],
);

useEffect(() => {
setHudMouseEventsEnabled(false);
Expand Down
Loading