From 47577c7623efc859c7f7a9c7da3f712807487f29 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Sun, 11 Jan 2026 09:50:51 -0800 Subject: [PATCH] Make top visual space for surface drag handles --- .../Surface View/SurfaceGrabHandle.swift | 39 +++++++------------ src/Surface.zig | 7 +++- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift b/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift index ff751df10..a4f5dddda 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift @@ -1,41 +1,30 @@ -import AppKit import SwiftUI extension Ghostty { /// A grab handle overlay at the top of the surface for dragging the window. - /// Only appears when hovering in the top region of the surface. struct SurfaceGrabHandle: View { - private let handleHeight: CGFloat = 10 - let surfaceView: SurfaceView @State private var isHovering: Bool = false @State private var isDragging: Bool = false var body: some View { - VStack(spacing: 0) { - Rectangle() - .fill(Color.primary.opacity(isHovering || isDragging ? 0.15 : 0)) - .frame(height: handleHeight) - .overlay(alignment: .center) { - if isHovering || isDragging { - Image(systemName: "ellipsis") - .font(.system(size: 14, weight: .semibold)) - .foregroundColor(.primary.opacity(0.5)) - } - } - .contentShape(Rectangle()) - .overlay { - SurfaceDragSource( - surfaceView: surfaceView, - isDragging: $isDragging, - isHovering: $isHovering - ) - } + ZStack { + SurfaceDragSource( + surfaceView: surfaceView, + isDragging: $isDragging, + isHovering: $isHovering + ) + .frame(width: 80, height: 12) + .contentShape(Rectangle()) - Spacer() + Image(systemName: "ellipsis") + .font(.system(size: 10, weight: .semibold)) + .foregroundColor(.primary.opacity(isHovering ? 0.8 : 0.3)) + .offset(y: -2) + .allowsHitTesting(false) } - .frame(maxWidth: .infinity, maxHeight: .infinity) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top) } } } diff --git a/src/Surface.zig b/src/Surface.zig index b9dbefa1b..02fe75718 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -427,9 +427,14 @@ const DerivedConfig = struct { } fn scaledPadding(self: *const DerivedConfig, x_dpi: f32, y_dpi: f32) rendererpkg.Padding { + // Add 6pt header height for macOS overlay elements (tight fit around ellipsis) + const header_height_pt: f32 = 6.0; + const header_height_px: u32 = @intFromFloat(@floor(header_height_pt * y_dpi / 72)); + const padding_top: u32 = padding_top: { const padding_top: f32 = @floatFromInt(self.window_padding_top); - break :padding_top @intFromFloat(@floor(padding_top * y_dpi / 72)); + const scaled_padding: u32 = @intFromFloat(@floor(padding_top * y_dpi / 72)); + break :padding_top scaled_padding + header_height_px; }; const padding_bottom: u32 = padding_bottom: { const padding_bottom: f32 = @floatFromInt(self.window_padding_bottom);