Skip to content

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

fix(hud): the drag region sat on the window root, not the grab handle

Etienne Lescot2bc9d706a41a
diff --git a/src/components/launch/HudControls.tsx b/src/components/launch/HudControls.tsx
index 788328059..360499c79 100644
--- a/src/components/launch/HudControls.tsx
+++ b/src/components/launch/HudControls.tsx
@@ -50,11 +50,26 @@ export const HudDivider = memo(function HudDivider({ vertical }: { vertical: boo
export const HudDragHandle = memo(function HudDragHandle({
vertical,
+ nativeDrag,
onPointerDown,
onPointerMove,
onPointerEnd,
}: {
vertical: boolean;
+ /**
+ * Hand the gesture to the compositor instead of the pointer handlers below.
+ *
+ * Wayland forbids a client from reading or setting its own global position:
+ * `getPosition()` answers [0, 0] and `setPosition()` only updates Electron's
+ * own cache, so the origin+delta scheme the handlers implement cannot move
+ * the window there. `-webkit-app-region: drag` is the one path that does —
+ * it routes to `xdg_toplevel.move` and the compositor performs the move.
+ *
+ * A drag region swallows pointer events, so the two are mutually exclusive:
+ * platforms that can position themselves keep the handler path, which gives
+ * finer control and lets the HUD suppress resizes mid-gesture.
+ */
+ nativeDrag: boolean;
onPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
onPointerMove: (event: React.PointerEvent<HTMLDivElement>) => void;
onPointerEnd: (event: React.PointerEvent<HTMLDivElement>) => void;
@@ -62,7 +77,9 @@ export const HudDragHandle = memo(function HudDragHandle({
return (
<div
data-testid="hud-drag-handle"
- className={`flex ${vertical ? "h-6 w-8" : "h-8 w-7"} shrink-0 cursor-grab items-center justify-center active:cursor-grabbing ${styles.electronNoDrag}`}
+ className={`flex ${vertical ? "h-6 w-8" : "h-8 w-7"} shrink-0 cursor-grab items-center justify-center active:cursor-grabbing ${
+ nativeDrag ? styles.electronDrag : styles.electronNoDrag
+ }`}
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={onPointerEnd}
diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx
index 722939ac5..c2021409d 100644
--- a/src/components/launch/LaunchWindow.tsx
+++ b/src/components/launch/LaunchWindow.tsx
@@ -732,7 +732,14 @@ export function LaunchWindow() {
// Avoid w-screen/h-screen: 100vw can exceed the inner layout width when scrollbars
// affect the viewport (Windows), causing a horizontal scrollbar (issue #305).
<div
- className={`h-full w-full min-w-0 max-w-full overflow-x-hidden overflow-y-hidden bg-transparent ${styles.electronDrag}`}
+ // No `electronDrag` here. This root is the whole 820x560 window, nearly all of
+ // it invisible, and a drag region is honoured by the compositor whether or not
+ // anything is painted there. On Windows/macOS that stayed hidden because
+ // `setIgnoreMouseEvents` makes the transparent area input-transparent at the OS
+ // level; on Linux that call is a no-op, so pressing empty space next to the bar
+ // dragged the HUD from a spot the user was aiming *past*. The drag region
+ // belongs on the grab handle, which is where it now lives.
+ className="h-full w-full min-w-0 max-w-full overflow-x-hidden overflow-y-hidden bg-transparent"
onPointerMove={handleRootPointerMove}
onPointerLeave={handlePointerLeave}
>
@@ -752,6 +759,7 @@ export function LaunchWindow() {
>
<HudDragHandle
vertical={isVertical}
+ nativeDrag={isLinuxHud}
onPointerDown={handleHudDragPointerDown}
onPointerMove={handleHudDragPointerMove}
onPointerEnd={handleHudDragPointerEnd}