summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Hashimoto <m@mitchellh.com>2025-04-13 14:58:31 -0700
committerGitHub <noreply@github.com>2025-04-13 14:58:31 -0700
commitf7394c00c12543742185d8ed682d64d2d6fa1586 (patch)
tree50a0462f8fd67d28ad16327d8e8219780fe6a9bf
parent66636195f18d21bd65f8e7ced461f6b6770be189 (diff)
parent6d80388155fe7cfd31005c20fc1c362bf6eaeeb9 (diff)
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.
-rw-r--r--macos/Sources/Ghostty/SurfaceView_AppKit.swift7
1 files changed, 7 insertions, 0 deletions
diff --git a/macos/Sources/Ghostty/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/SurfaceView_AppKit.swift
index c6a3d7629..230d3a9e2 100644
--- a/macos/Sources/Ghostty/SurfaceView_AppKit.swift
+++ b/macos/Sources/Ghostty/SurfaceView_AppKit.swift
@@ -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)