mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: cannot call mouseEntered/Exited with blank NSEvent
Fixes #2283 macOS <= 14 crash with an invalid NSEvent error. macOS 15 seems to just ignore the blank event. We just got lucky with this. Since we don't override mouseEntered/Exited anymore we can remove this completely. The regression was from: e89a4f74089b66c00043096589dc75fff5ab6674
This commit is contained in:
@ -233,25 +233,6 @@ extension Ghostty {
|
||||
// The size represents our final size we're going for.
|
||||
let scaledSize = self.convertToBacking(size)
|
||||
setSurfaceSize(width: UInt32(scaledSize.width), height: UInt32(scaledSize.height))
|
||||
|
||||
// Frame changes do not always call mouseEntered/mouseExited, so we do some
|
||||
// calculations ourself to call those events.
|
||||
if let window = self.window {
|
||||
let mouseScreen = NSEvent.mouseLocation
|
||||
let mouseWindow = window.convertPoint(fromScreen: mouseScreen)
|
||||
let mouseView = self.convert(mouseWindow, from: nil)
|
||||
let isEntered = self.isMousePoint(mouseView, in: bounds)
|
||||
if (isEntered) {
|
||||
mouseEntered(with: NSEvent())
|
||||
} else {
|
||||
mouseExited(with: NSEvent())
|
||||
}
|
||||
} else {
|
||||
// If we don't have a window, then our mouse can NOT be in our view.
|
||||
// When the window comes back, I believe this event fires again so
|
||||
// we'll get a mouseEntered.
|
||||
mouseExited(with: NSEvent())
|
||||
}
|
||||
}
|
||||
|
||||
private func setSurfaceSize(width: UInt32, height: UInt32) {
|
||||
@ -261,7 +242,13 @@ extension Ghostty {
|
||||
ghostty_surface_set_size(surface, width, height)
|
||||
|
||||
// Update our cached size metrics
|
||||
self.surfaceSize = ghostty_surface_size(surface)
|
||||
let size = ghostty_surface_size(surface)
|
||||
DispatchQueue.main.async {
|
||||
// DispatchQueue required since this may be called by SwiftUI off
|
||||
// the main thread and Published changes need to be on the main
|
||||
// thread. This caused a crash on macOS <= 14.
|
||||
self.surfaceSize = size
|
||||
}
|
||||
}
|
||||
|
||||
func setCursorShape(_ shape: ghostty_mouse_shape_e) {
|
||||
|
Reference in New Issue
Block a user