From 227eda1d0998b3b60130edfaed16750135091966 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 6 Oct 2024 15:09:37 -1000 Subject: [PATCH] macos: notify core of mouse exit --- macos/Sources/Ghostty/SurfaceView_AppKit.swift | 9 +++++++++ 1 file changed, 9 insertions(+) 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 }