From fc64dfa31142757708c5716f25db916c1baa5bf7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 26 Feb 2023 17:26:17 -0800 Subject: [PATCH] macos: on resize do not use the view frame See the comment in the diff. --- macos/Sources/TerminalSurfaceView.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/macos/Sources/TerminalSurfaceView.swift b/macos/Sources/TerminalSurfaceView.swift index d4f3c4813..c790646ed 100644 --- a/macos/Sources/TerminalSurfaceView.swift +++ b/macos/Sources/TerminalSurfaceView.swift @@ -263,9 +263,12 @@ class TerminalSurfaceView_Real: NSView, NSTextInputClient, ObservableObject { func sizeDidChange(_ size: CGSize) { guard let surface = self.surface else { return } - // Ghostty wants to know the actual framebuffer size... - let fbFrame = self.convertToBacking(self.frame); - ghostty_surface_set_size(surface, UInt32(fbFrame.size.width), UInt32(fbFrame.size.height)) + // Ghostty wants to know the actual framebuffer size... It is very important + // here that we use "size" and NOT the view frame. If we're in the middle of + // an animation (i.e. a fullscreen animation), the frame will not yet be updated. + // The size represents our final size we're going for. + let scaledSize = self.convertToBacking(size) + ghostty_surface_set_size(surface, UInt32(scaledSize.width), UInt32(scaledSize.height)) } override func updateTrackingAreas() {