mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
metal: use the screen size reported in the callback to resize
We were previously using the bounds which might be updated later if the view is in the middle of an animation. Just use the size that represents our target state.
This commit is contained in:
@ -695,23 +695,7 @@ fn drawCells(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Resize the screen.
|
/// Resize the screen.
|
||||||
pub fn setScreenSize(self: *Metal, _: renderer.ScreenSize) !void {
|
pub fn setScreenSize(self: *Metal, dim: renderer.ScreenSize) !void {
|
||||||
// We use the bounds of our view which should be updated by now.
|
|
||||||
const unscaled = self.swapchain.getProperty(macos.graphics.Rect, "bounds");
|
|
||||||
const bounds: macos.graphics.Size = scaled: {
|
|
||||||
const scaleFactor = self.swapchain.getProperty(macos.graphics.c.CGFloat, "contentsScale");
|
|
||||||
break :scaled .{
|
|
||||||
.width = unscaled.size.width * scaleFactor,
|
|
||||||
.height = unscaled.size.height * scaleFactor,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Easier to work with our own types
|
|
||||||
const dim: renderer.ScreenSize = .{
|
|
||||||
.width = @floatToInt(u32, bounds.width),
|
|
||||||
.height = @floatToInt(u32, bounds.height),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Recalculate the rows/columns.
|
// Recalculate the rows/columns.
|
||||||
const grid_size = self.gridSize(dim);
|
const grid_size = self.gridSize(dim);
|
||||||
|
|
||||||
@ -732,7 +716,10 @@ pub fn setScreenSize(self: *Metal, _: renderer.ScreenSize) !void {
|
|||||||
self.font_shaper.cell_buf = shape_buf;
|
self.font_shaper.cell_buf = shape_buf;
|
||||||
|
|
||||||
// Set the size of the drawable surface to the bounds
|
// Set the size of the drawable surface to the bounds
|
||||||
self.swapchain.setProperty("drawableSize", bounds);
|
self.swapchain.setProperty("drawableSize", macos.graphics.Size{
|
||||||
|
.width = @intToFloat(f64, dim.width),
|
||||||
|
.height = @intToFloat(f64, dim.height),
|
||||||
|
});
|
||||||
|
|
||||||
// Setup our uniforms
|
// Setup our uniforms
|
||||||
const old = self.uniforms;
|
const old = self.uniforms;
|
||||||
|
Reference in New Issue
Block a user