From e76de71f3e12f35e623411a6c0f0e0d868a01e71 Mon Sep 17 00:00:00 2001 From: austinpower1258 Date: Tue, 24 Feb 2026 14:18:58 -0800 Subject: [PATCH] Fix sidebar titlebar drag and double-click passthrough --- Sources/BrowserWindowPortal.swift | 8 ++++++-- Sources/ContentView.swift | 27 +++------------------------ 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/Sources/BrowserWindowPortal.swift b/Sources/BrowserWindowPortal.swift index 448f0e46..1a5ea166 100644 --- a/Sources/BrowserWindowPortal.swift +++ b/Sources/BrowserWindowPortal.swift @@ -133,9 +133,13 @@ final class WindowBrowserHostView: NSView { private func shouldPassThroughToTitlebar(at point: NSPoint) -> Bool { guard let window else { return false } // Window-level portal hosts sit above SwiftUI content. Never intercept - // hits that land in the native titlebar region. + // hits that land in native titlebar space or the custom titlebar strip + // we reserve directly under it for window drag/double-click behaviors. let windowPoint = convert(point, to: nil) - return windowPoint.y >= (window.contentLayoutRect.maxY - 0.5) + let nativeTitlebarHeight = window.frame.height - window.contentLayoutRect.height + let customTitlebarBandHeight = max(28, min(72, nativeTitlebarHeight)) + let interactionBandMinY = window.contentLayoutRect.maxY - customTitlebarBandHeight - 0.5 + return windowPoint.y >= interactionBandMinY } private func shouldPassThroughToSidebarResizer(at point: NSPoint) -> Bool { diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index 3a21ed9d..8f3e6157 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -5241,9 +5241,9 @@ struct VerticalTabsSidebar: View { .allowsHitTesting(false) } .overlay(alignment: .top) { - // Double-click the sidebar title-bar area to trigger the - // standard macOS titlebar action (zoom/minimize). - DoubleClickZoomView() + // Match native titlebar behavior in the sidebar top strip: + // drag-to-move and double-click action (zoom/minimize). + WindowDragHandleView() .frame(height: trafficLightPadding) } .background(Color.clear) @@ -7479,27 +7479,6 @@ private struct SidebarTabDropDelegate: DropDelegate { } } -/// AppKit-level double-click handler for the sidebar title-bar area. -/// Uses NSView hit-testing so it isn't swallowed by the SwiftUI ScrollView underneath. -private struct DoubleClickZoomView: NSViewRepresentable { - func makeNSView(context: Context) -> NSView { - DoubleClickZoomNSView() - } - - func updateNSView(_ nsView: NSView, context: Context) {} - - private final class DoubleClickZoomNSView: NSView { - override var mouseDownCanMoveWindow: Bool { true } - override func hitTest(_ point: NSPoint) -> NSView? { self } - override func mouseDown(with event: NSEvent) { - if event.clickCount == 2, performStandardTitlebarDoubleClick(window: window) { - return - } - super.mouseDown(with: event) - } - } -} - private struct MiddleClickCapture: NSViewRepresentable { let onMiddleClick: () -> Void