Open source CapCut alternative.
TypeScript
Fix overlay issue
David Le11d5e5420889
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swiftindex 81edffef..a14bea14 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift@@ -13,7 +13,7 @@ final class PointerPromptOverlayController {private let microphoneWaveformMeter = MicrophoneWaveformMeter()private var statusPanel: NSPanel?- private var statusHostingView: NSHostingView<PointerPromptNotchStatusView>?+ private var statusHostingView: PointerPromptHostingView<PointerPromptNotchStatusView>?private var inputPanel: NSPanel?private var timer: Timer?private var globalActivationMonitor: Any?@@ -113,11 +113,14 @@ final class PointerPromptOverlayController {private func makeStatusPanel() -> NSPanel {let metrics = notchMetrics()- let hostingView = NSHostingView(rootView: notchStatusView(metrics: metrics))+ let hostingView = PointerPromptHostingView(rootView: notchStatusView(metrics: metrics))hostingView.frame = CGRect(origin: .zero, size: metrics.surfaceSize)hostingView.autoresizingMask = [.width, .height]hostingView.wantsLayer = true- hostingView.layer?.backgroundColor = NSColor.clear.cgColor+ configureStatusHostingLayer(hostingView, metrics: metrics)+ hostingView.hitTestRegionProvider = { [weak self] in+ self?.statusHitTestRegions() ?? []+ }statusHostingView = hostingViewlastStatusViewSnapshot = statusViewSnapshot(metrics: metrics)@@ -494,9 +497,26 @@ final class PointerPromptOverlayController {}lastStatusViewSnapshot = snapshot+ if let statusHostingView {+ configureStatusHostingLayer(statusHostingView, metrics: metrics)+ }statusHostingView?.rootView = notchStatusView(metrics: metrics)}+ private func configureStatusHostingLayer(+ _ hostingView: PointerPromptHostingView<PointerPromptNotchStatusView>,+ metrics: NotchMetrics+ ) {+ hostingView.layer?.backgroundColor = statusHostDebugBackgroundColor?.cgColor+ hostingView.layer?.cornerRadius = metrics.hostCornerRadius+ hostingView.layer?.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]+ hostingView.layer?.masksToBounds = true+ }++ private var statusHostDebugBackgroundColor: NSColor? {+ nil+ }+private func statusViewSnapshot(metrics: NotchMetrics) -> StatusPanelViewSnapshot {StatusPanelViewSnapshot(state: model.promptState,@@ -566,11 +586,20 @@ final class PointerPromptOverlayController {if metrics.hoverFramesInPanel.contains(where: { $0.contains(mouseLocationInPanel) }) {setStatusExpanded(true)- } else if statusHoverPhase != .collapsed, statusCollapseWorkItem == nil {+ } else if statusHoverPhase != .collapsed,+ statusHoverPhase != .closing,+ statusCollapseWorkItem == nil {scheduleStatusCollapse()}}+ private func statusHitTestRegions() -> [CGRect] {+ guard let statusPanel else { return [] }++ let metrics = notchMetrics(for: statusPanel.screen)+ return [metrics.visibleSurfaceFrameInPanel]+ }+private func setStatusExpanded(_ isExpanded: Bool) {if isExpanded {statusCollapseWorkItem?.cancel()@@ -619,7 +648,9 @@ final class PointerPromptOverlayController {guard statusHoverPhase != .collapsed else { return }guard statusHoverPhase != .closing else {- scheduleStatusHostShrink()+ if statusHostShrinkWorkItem == nil {+ scheduleStatusHostShrink()+ }return}@@ -684,11 +715,8 @@ final class PointerPromptOverlayController {}private func scheduleStatusHostShrink() {- statusHostShrinkWorkItem?.cancel()+ guard statusHostShrinkWorkItem == nil else { return }- // Wait for SwiftUI's short close animation, then collapse the transparent- // host without animation. Shrinking it earlier changes the coordinate- // space while the visible surface is still animating.let workItem = DispatchWorkItem { [weak self] inTask { @MainActor inself?.shrinkStatusHostIfCollapsed()@@ -1078,6 +1106,19 @@ private final class PointerPromptPanel: NSPanel {}}+private final class PointerPromptHostingView<Content: View>: NSHostingView<Content> {+ var hitTestRegionProvider: (() -> [CGRect])?++ override func hitTest(_ point: NSPoint) -> NSView? {+ if let hitTestRegionProvider,+ !hitTestRegionProvider().contains(where: { $0.contains(point) }) {+ return nil+ }++ return super.hitTest(point)+ }+}+private struct NotchMetrics {static let fallbackVoidWidth: CGFloat = 180static let fallbackVoidHeight: CGFloat = 32@@ -1095,6 +1136,10 @@ private struct NotchMetrics {surfaceFrame.size}+ var hostCornerRadius: CGFloat {+ isHostExpanded ? Self.expandedCornerRadius : Self.collapsedCornerRadius+ }+var visibleSurfaceFrameInPanel: CGRect {frameInPanel(for: visibleSurfaceFrame)}