padding needs to be sent to termio

This commit is contained in:
Mitchell Hashimoto
2022-11-14 17:25:35 -08:00
parent d7d12d9469
commit 860fbc3aee
4 changed files with 16 additions and 4 deletions

View File

@ -586,7 +586,8 @@ fn sizeCallback(window: glfw.Window, width: i32, height: i32) void {
_ = win.io_thread.mailbox.push(.{ _ = win.io_thread.mailbox.push(.{
.resize = .{ .resize = .{
.grid_size = win.grid_size, .grid_size = win.grid_size,
.screen_size = screen_size.subPadding(win.padding), .screen_size = screen_size,
.padding = win.padding,
}, },
}, .{ .forever = {} }); }, .{ .forever = {} });
win.io_thread.wakeup.send() catch {}; win.io_thread.wakeup.send() catch {};

View File

@ -231,13 +231,16 @@ pub fn resize(
self: *Exec, self: *Exec,
grid_size: renderer.GridSize, grid_size: renderer.GridSize,
screen_size: renderer.ScreenSize, screen_size: renderer.ScreenSize,
padding: renderer.Padding,
) !void { ) !void {
const padded_size = screen_size.subPadding(padding);
// Update the size of our pty // Update the size of our pty
try self.pty.setSize(.{ try self.pty.setSize(.{
.ws_row = @intCast(u16, grid_size.rows), .ws_row = @intCast(u16, grid_size.rows),
.ws_col = @intCast(u16, grid_size.columns), .ws_col = @intCast(u16, grid_size.columns),
.ws_xpixel = @intCast(u16, screen_size.width), .ws_xpixel = @intCast(u16, padded_size.width),
.ws_ypixel = @intCast(u16, screen_size.height), .ws_ypixel = @intCast(u16, padded_size.height),
}); });
// Update our cached grid size // Update our cached grid size

View File

@ -172,7 +172,7 @@ fn drainMailbox(self: *Thread) !void {
log.debug("mailbox message={}", .{message}); log.debug("mailbox message={}", .{message});
switch (message) { switch (message) {
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size), .resize => |v| try self.impl.resize(v.grid_size, v.screen_size, v.padding),
.write_small => |v| try self.impl.queueWrite(v.data[0..v.len]), .write_small => |v| try self.impl.queueWrite(v.data[0..v.len]),
.write_stable => |v| try self.impl.queueWrite(v), .write_stable => |v| try self.impl.queueWrite(v),
.write_alloc => |v| { .write_alloc => |v| {

View File

@ -12,8 +12,16 @@ const terminal = @import("../terminal/main.zig");
pub const Message = union(enum) { pub const Message = union(enum) {
/// Resize the window. /// Resize the window.
resize: struct { resize: struct {
/// The grid size for the given screen size with padding applied.
grid_size: renderer.GridSize, grid_size: renderer.GridSize,
/// The full screen (drawable) size. This does NOT include padding.
/// This should be sent on to the renderer.
screen_size: renderer.ScreenSize, screen_size: renderer.ScreenSize,
/// The padding, so that the terminal implementation can subtract
/// this to send to the pty.
padding: renderer.Padding,
}, },
/// Write where the data fits in the union. /// Write where the data fits in the union.