mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
termio: change resize message to use new size struct
This commit is contained in:
@ -1365,14 +1365,7 @@ fn setCellSize(self: *Surface, size: renderer.CellSize) !void {
|
||||
if (self.config.window_padding_balance) self.size.balancePadding();
|
||||
|
||||
// Notify the terminal
|
||||
self.io.queueMessage(.{
|
||||
.resize = .{
|
||||
.grid_size = self.size.grid(),
|
||||
.cell_size = self.size.cell,
|
||||
.screen_size = self.size.screen,
|
||||
.padding = self.size.padding,
|
||||
},
|
||||
}, .unlocked);
|
||||
self.io.queueMessage(.{ .resize = self.size }, .unlocked);
|
||||
|
||||
// Notify the window
|
||||
try self.rt_app.performAction(
|
||||
@ -1468,14 +1461,7 @@ fn resize(self: *Surface, size: renderer.ScreenSize) !void {
|
||||
}
|
||||
|
||||
// Mail the IO thread
|
||||
self.io.queueMessage(.{
|
||||
.resize = .{
|
||||
.grid_size = grid_size,
|
||||
.cell_size = self.size.cell,
|
||||
.screen_size = self.size.screen,
|
||||
.padding = self.size.padding,
|
||||
},
|
||||
}, .unlocked);
|
||||
self.io.queueMessage(.{ .resize = self.size }, .unlocked);
|
||||
}
|
||||
|
||||
/// Called to set the preedit state for character input. Preedit is used
|
||||
|
@ -25,6 +25,12 @@ pub const Size = struct {
|
||||
return GridSize.init(self.screen.subPadding(self.padding), self.cell);
|
||||
}
|
||||
|
||||
/// The size of the terminal. This is the same as the screen without
|
||||
/// padding.
|
||||
pub fn terminal(self: Size) ScreenSize {
|
||||
return self.screen.subPadding(self.padding);
|
||||
}
|
||||
|
||||
/// Set the padding to be balanced around the grid. Overwrites the current
|
||||
/// padding.
|
||||
pub fn balancePadding(self: *Size) void {
|
||||
|
@ -349,18 +349,16 @@ pub fn changeConfig(self: *Termio, td: *ThreadData, config: *DerivedConfig) !voi
|
||||
pub fn resize(
|
||||
self: *Termio,
|
||||
td: *ThreadData,
|
||||
grid_size: renderer.GridSize,
|
||||
cell_size: renderer.CellSize,
|
||||
screen_size: renderer.ScreenSize,
|
||||
padding: renderer.Padding,
|
||||
size: renderer.Size,
|
||||
) !void {
|
||||
const grid_size = size.grid();
|
||||
|
||||
// Update the size of our pty.
|
||||
const padded_size = screen_size.subPadding(padding);
|
||||
try self.backend.resize(grid_size, padded_size);
|
||||
try self.backend.resize(grid_size, size.terminal());
|
||||
|
||||
// Update our cached grid size
|
||||
self.grid_size = grid_size;
|
||||
self.cell_size = cell_size;
|
||||
self.grid_size = size.grid();
|
||||
self.cell_size = size.cell;
|
||||
|
||||
// Enter the critical area that we want to keep small
|
||||
{
|
||||
@ -375,8 +373,8 @@ pub fn resize(
|
||||
);
|
||||
|
||||
// Update our pixel sizes
|
||||
self.terminal.width_px = self.grid_size.columns * self.cell_size.width;
|
||||
self.terminal.height_px = self.grid_size.rows * self.cell_size.height;
|
||||
self.terminal.width_px = grid_size.columns * self.cell_size.width;
|
||||
self.terminal.height_px = grid_size.rows * self.cell_size.height;
|
||||
|
||||
// Disable synchronized output mode so that we show changes
|
||||
// immediately for a resize. This is allowed by the spec.
|
||||
@ -391,8 +389,8 @@ pub fn resize(
|
||||
// Mail the renderer so that it can update the GPU and re-render
|
||||
_ = self.renderer_mailbox.push(.{
|
||||
.resize = .{
|
||||
.screen_size = screen_size,
|
||||
.padding = padding,
|
||||
.screen_size = size.screen,
|
||||
.padding = size.padding,
|
||||
},
|
||||
}, .{ .forever = {} });
|
||||
self.renderer_wakeup.notify() catch {};
|
||||
|
@ -17,6 +17,7 @@ const builtin = @import("builtin");
|
||||
const xev = @import("xev");
|
||||
const crash = @import("../crash/main.zig");
|
||||
const termio = @import("../termio.zig");
|
||||
const renderer = @import("../renderer.zig");
|
||||
const BlockingQueue = @import("../datastruct/main.zig").BlockingQueue;
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
@ -28,7 +29,7 @@ const Coalesce = struct {
|
||||
/// Not all message types are coalesced.
|
||||
const min_ms = 25;
|
||||
|
||||
resize: ?termio.Message.Resize = null,
|
||||
resize: ?renderer.Size = null,
|
||||
};
|
||||
|
||||
/// The number of milliseconds before we reset the synchronized output flag
|
||||
@ -324,7 +325,7 @@ fn startSynchronizedOutput(self: *Thread, cb: *CallbackData) void {
|
||||
);
|
||||
}
|
||||
|
||||
fn handleResize(self: *Thread, cb: *CallbackData, resize: termio.Message.Resize) void {
|
||||
fn handleResize(self: *Thread, cb: *CallbackData, resize: renderer.Size) void {
|
||||
self.coalesce_data.resize = resize;
|
||||
|
||||
// If the timer is already active we just return. In the future we want
|
||||
@ -380,13 +381,7 @@ fn coalesceCallback(
|
||||
|
||||
if (cb.self.coalesce_data.resize) |v| {
|
||||
cb.self.coalesce_data.resize = null;
|
||||
cb.io.resize(
|
||||
&cb.data,
|
||||
v.grid_size,
|
||||
v.cell_size,
|
||||
v.screen_size,
|
||||
v.padding,
|
||||
) catch |err| {
|
||||
cb.io.resize(&cb.data, v) catch |err| {
|
||||
log.warn("error during resize err={}", .{err});
|
||||
};
|
||||
}
|
||||
|
@ -16,22 +16,6 @@ pub const Message = union(enum) {
|
||||
/// in the future.
|
||||
pub const WriteReq = MessageData(u8, 38);
|
||||
|
||||
pub const Resize = struct {
|
||||
/// The grid size for the given screen size with padding applied.
|
||||
grid_size: renderer.GridSize,
|
||||
|
||||
/// The updated cell size.
|
||||
cell_size: renderer.CellSize,
|
||||
|
||||
/// The full screen (drawable) size. This does NOT include padding.
|
||||
/// This should be sent on to the renderer.
|
||||
screen_size: renderer.ScreenSize,
|
||||
|
||||
/// The padding, so that the terminal implementation can subtract
|
||||
/// this to send to the pty.
|
||||
padding: renderer.Padding,
|
||||
};
|
||||
|
||||
/// Purposely crash the renderer. This is used for testing and debugging.
|
||||
/// See the "crash" binding action.
|
||||
crash: void,
|
||||
@ -47,7 +31,7 @@ pub const Message = union(enum) {
|
||||
inspector: bool,
|
||||
|
||||
/// Resize the window.
|
||||
resize: Resize,
|
||||
resize: renderer.Size,
|
||||
|
||||
/// Request a size report is sent to the pty ([in-band
|
||||
/// size report, mode 2048](https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83) and
|
||||
|
Reference in New Issue
Block a user