macos: prevent mouseEntered/Exited processing if already in that state

See the comment in the code.

Fixes #494
pull/501/head
Mitchell Hashimoto 2023-09-20 08:53:31 -07:00
parent ca20bda3e9
commit 6cee9e57f6
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
1 changed files with 9 additions and 0 deletions

View File

@ -491,6 +491,12 @@ extension Ghostty {
}
override func mouseEntered(with event: NSEvent) {
// For reasons unknown (Cocoaaaaaaaaa), mouseEntered is called
// multiple times in an unbalanced way with mouseExited when a new
// tab is created. In this scenario, we only want to process our
// callback once since this is stateful and we expect balancing.
if (mouseEntered) { return }
mouseEntered = true
// If our cursor is hidden, we hide it on upon entry and we unhide
@ -501,6 +507,9 @@ extension Ghostty {
}
override func mouseExited(with event: NSEvent) {
// See mouseEntered
if (!mouseEntered) { return }
mouseEntered = false
if (cursorVisible == .hidden) {