macOS: only emit a mouse exited position if we're not dragging (#7077)

Fixes #7071

When the mouse is being actively dragged, AppKit continues to emit
mouseDragged events which will update our position appropriately. The
mouseExit event we were sending sends a synthetic (-1, -1) position
which was causing a scroll up.
pull/7085/head
Mitchell Hashimoto 2025-04-13 14:58:31 -07:00 committed by GitHub
commit f7394c00c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -743,6 +743,13 @@ extension Ghostty {
override func mouseExited(with event: NSEvent) {
guard let surface = self.surface else { return }
// If the mouse is being dragged then we don't have to emit
// this because we get mouse drag events even if we've already
// exited the viewport (i.e. mouseDragged)
if NSEvent.pressedMouseButtons != 0 {
return
}
// Negative values indicate cursor has left the viewport
let mods = Ghostty.ghosttyMods(event.modifierFlags)
ghostty_surface_mouse_pos(surface, -1, -1, mods)