diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index 4364fa01..6993ff69 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -579,6 +579,12 @@ struct VerticalTabsSidebar: View { SidebarTopScrim(height: trafficLightPadding + 20) .allowsHitTesting(false) } + .overlay(alignment: .top) { + // Double-click the sidebar title-bar area to zoom the + // window, matching the panel top-bar behaviour. + DoubleClickZoomView() + .frame(height: trafficLightPadding) + } .background(Color.clear) .modifier(ClearScrollBackground()) } @@ -1920,6 +1926,28 @@ 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 { + window?.zoom(nil) + } else { + super.mouseDown(with: event) + } + } + } +} + private struct MiddleClickCapture: NSViewRepresentable { let onMiddleClick: () -> Void