Skip to content

Open source CapCut alternative.

TypeScript

fix(app): unflip the spawn panel's mouse passthrough hit test

David Le3b3d59832e6a
diff --git a/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift
index e7c2755a..79703c76 100644
--- a/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift
@@ -664,10 +664,28 @@ final class UserQuerySpawnOverlayController {
return
}
- let mouseLocation = surface.panel.convertPoint(fromScreen: NSEvent.mouseLocation)
+ let mouseLocation = overlayLocalPoint(
+ for: NSEvent.mouseLocation,
+ in: surface
+ )
surface.panel.ignoresMouseEvents = !hitTestFrame.contains(mouseLocation)
}
+ /// Converts a global screen point into the overlay's top-left-origin local
+ /// space. `convertPoint(fromScreen:)` alone is not enough: it returns
+ /// bottom-left-origin window coordinates, and comparing those against the
+ /// flipped `localHitTestFrame` mirrors the interactive region vertically.
+ private func overlayLocalPoint(
+ for screenPoint: CGPoint,
+ in surface: UserQuerySpawnSurface
+ ) -> CGPoint {
+ let windowPoint = surface.panel.convertPoint(fromScreen: screenPoint)
+ return CGPoint(
+ x: windowPoint.x,
+ y: surface.panel.frame.height - windowPoint.y
+ )
+ }
+
/// `ignoresMouseEvents` is only as fresh as its last evaluation, which
/// otherwise happens on model updates and layout changes. Without a
/// movement monitor, mousing over a quiet holding pointer leaves its panel
@@ -847,7 +865,7 @@ final class UserQuerySpawnOverlayController {
) -> Bool {
guard surface.panel.frame.contains(screenPoint) else { return false }
- let localPoint = surface.panel.convertPoint(fromScreen: screenPoint)
+ let localPoint = overlayLocalPoint(for: screenPoint, in: surface)
return surface.viewModel.localHitTestFrame.contains(localPoint)
}