core: send pixel-level surface sizing to the pty

This commit is contained in:
Mitchell Hashimoto
2023-08-18 13:17:23 -07:00
parent e7ab16f0e1
commit 3ca759bac6
2 changed files with 8 additions and 6 deletions

View File

@ -894,14 +894,12 @@ pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
// Recalculate our grid size. Because Ghostty supports fluid resizing,
// its possible the grid doesn't change at all even if the screen size changes.
const new_grid_size = renderer.GridSize.init(
// We have to update the IO thread no matter what because we send
// pixel-level sizing to the subprocess.
self.grid_size = renderer.GridSize.init(
self.screen_size.subPadding(self.padding),
self.cell_size,
);
if (self.grid_size.equals(new_grid_size)) return;
// Grid size changed, update our grid size and notify the terminal
self.grid_size = new_grid_size;
if (self.grid_size.columns < 5 and (self.padding.left > 0 or self.padding.right > 0)) {
log.warn("WARNING: very small terminal grid detected with padding " ++
"set. Is your padding reasonable?", .{});

View File

@ -256,10 +256,14 @@ pub fn resize(
screen_size: renderer.ScreenSize,
padding: renderer.Padding,
) !void {
// Update the size of our pty
// Update the size of our pty.
const padded_size = screen_size.subPadding(padding);
try self.subprocess.resize(grid_size, padded_size);
// If our grid size didn't change, then we don't need to change
// the underlying terminal.
if (grid_size.equals(self.grid_size)) return;
// Update our cached grid size
self.grid_size = grid_size;