diff --git a/macos/Sources/Ghostty/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/SurfaceView_AppKit.swift index 592611f32..1e9708f0f 100644 --- a/macos/Sources/Ghostty/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/SurfaceView_AppKit.swift @@ -354,6 +354,7 @@ extension Ghostty { addTrackingArea(NSTrackingArea( rect: frame, options: [ + .mouseEnteredAndExited, .mouseMoved, // Only send mouse events that happen in our visible (not obscured) rect @@ -486,6 +487,14 @@ extension Ghostty { super.rightMouseUp(with: event) } + override func mouseExited(with event: NSEvent) { + guard let surface = self.surface else { return } + + // Negative values indicate cursor has left the viewport + let mods = Ghostty.ghosttyMods(event.modifierFlags) + ghostty_surface_mouse_pos(surface, -1, -1, mods) + } + override func mouseMoved(with event: NSEvent) { guard let surface = self.surface else { return }