Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

Keep HUD interactive on Linux so the drag handle can receive pointer events

EtienneLescot8246d0715b24
diff --git a/src/components/launch/LaunchWindow.test.tsx b/src/components/launch/LaunchWindow.test.tsx
index 6440f1d41..29a67374b 100644
--- a/src/components/launch/LaunchWindow.test.tsx
+++ b/src/components/launch/LaunchWindow.test.tsx
@@ -8,6 +8,8 @@ type SelectedSourceChangedListener = Parameters<
Window["electronAPI"]["onSelectedSourceChanged"]
>[0];
+const platformState = vi.hoisted(() => ({ value: "darwin" }));
+
const recorderState = vi.hoisted(() => ({
value: {
recording: false,
@@ -71,7 +73,7 @@ vi.mock("../../lib/requestCameraAccess", () => ({
vi.mock("@/native", () => ({
nativeBridgeClient: {
system: {
- getPlatform: vi.fn(async () => "darwin"),
+ getPlatform: vi.fn(async () => platformState.value),
},
},
}));
@@ -190,6 +192,7 @@ function emitSourceSelectorClosed() {
describe("LaunchWindow record button", () => {
beforeEach(() => {
+ platformState.value = "darwin";
class ResizeObserver {
observe() {
return undefined;
@@ -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);
+ });
+ });
});
diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx
index 511ab8e5c..6b614caae 100644
--- a/src/components/launch/LaunchWindow.tsx
+++ b/src/components/launch/LaunchWindow.tsx
@@ -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);
@@ -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);
}
});
@@ -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);