Merge pull request #438 from manaflow-ai/cmux/titlebar-issues
Fix sidebar titlebar drag and double-click passthrough
This commit is contained in:
commit
1f7f5de6ce
2 changed files with 9 additions and 26 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue