From 860fbc3aee45e6e49fd9156e3913e9dd09f61288 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 14 Nov 2022 17:25:35 -0800 Subject: [PATCH] padding needs to be sent to termio --- src/Window.zig | 3 ++- src/termio/Exec.zig | 7 +++++-- src/termio/Thread.zig | 2 +- src/termio/message.zig | 8 ++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Window.zig b/src/Window.zig index 1ea177465..a96cd73fb 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -586,7 +586,8 @@ fn sizeCallback(window: glfw.Window, width: i32, height: i32) void { _ = win.io_thread.mailbox.push(.{ .resize = .{ .grid_size = win.grid_size, - .screen_size = screen_size.subPadding(win.padding), + .screen_size = screen_size, + .padding = win.padding, }, }, .{ .forever = {} }); win.io_thread.wakeup.send() catch {}; diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 8926ea671..cb7b8f6e6 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -231,13 +231,16 @@ pub fn resize( self: *Exec, grid_size: renderer.GridSize, screen_size: renderer.ScreenSize, + padding: renderer.Padding, ) !void { + const padded_size = screen_size.subPadding(padding); + // Update the size of our pty try self.pty.setSize(.{ .ws_row = @intCast(u16, grid_size.rows), .ws_col = @intCast(u16, grid_size.columns), - .ws_xpixel = @intCast(u16, screen_size.width), - .ws_ypixel = @intCast(u16, screen_size.height), + .ws_xpixel = @intCast(u16, padded_size.width), + .ws_ypixel = @intCast(u16, padded_size.height), }); // Update our cached grid size diff --git a/src/termio/Thread.zig b/src/termio/Thread.zig index e8db4d3ff..7c75d9603 100644 --- a/src/termio/Thread.zig +++ b/src/termio/Thread.zig @@ -172,7 +172,7 @@ fn drainMailbox(self: *Thread) !void { log.debug("mailbox message={}", .{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_stable => |v| try self.impl.queueWrite(v), .write_alloc => |v| { diff --git a/src/termio/message.zig b/src/termio/message.zig index 623c41b40..9c03cf1e6 100644 --- a/src/termio/message.zig +++ b/src/termio/message.zig @@ -12,8 +12,16 @@ const terminal = @import("../terminal/main.zig"); pub const Message = union(enum) { /// Resize the window. resize: struct { + /// The grid size for the given screen size with padding applied. 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, + + /// 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.