Commit 7381df3
이영수
·
2026-06-28 09:25:44 -0400 EDT
parent 4e2d02b
fix: forward real terminal pixel size instead of hardcoding 0x0 (#174)
ipc.Resize only carried rows/cols, and getTerminalSize() dropped the
ws_xpixel/ws_ypixel fields read from TIOCGWINSZ. The daemon's three
TIOCSWINSZ call sites (spawnPty, handleInit, handleResize) then hardcoded
ws_xpixel/ws_ypixel to 0 on the inner pty, regardless of what the real
terminal reported.
This breaks Kitty graphics-protocol image sizing for anything running
inside a zmx session, since image dimensions in cells get computed from
a pixel-per-cell ratio that is always 0. nvim plugins like snacks.nvim
report `{cell}: 0 x 0 pixels` and scale images to nothing before sending
them to the terminal.
Add xpixel/ypixel to ipc.Resize, populate them from the real
ioctl(TIOCGWINSZ) result on the client side, and thread them through to
the daemon's TIOCSWINSZ calls instead of hardcoding 0.
2 files changed,
+9,
-7
+3,
-1
1@@ -38,12 +38,14 @@ pub const Header = packed struct {
2 pub const Resize = packed struct {
3 rows: u16,
4 cols: u16,
5+ xpixel: u16 = 0,
6+ ypixel: u16 = 0,
7 };
8
9 pub fn getTerminalSize(fd: i32) Resize {
10 var ws: cross.c.struct_winsize = undefined;
11 if (cross.c.ioctl(fd, cross.c.TIOCGWINSZ, &ws) == 0 and ws.ws_row > 0 and ws.ws_col > 0) {
12- return .{ .rows = ws.ws_row, .cols = ws.ws_col };
13+ return .{ .rows = ws.ws_row, .cols = ws.ws_col, .xpixel = ws.ws_xpixel, .ypixel = ws.ws_ypixel };
14 }
15 return .{ .rows = 24, .cols = 160 };
16 }
+6,
-6
1@@ -702,8 +702,8 @@ const Daemon = struct {
2 var ws: cross.c.struct_winsize = .{
3 .ws_row = size.rows,
4 .ws_col = size.cols,
5- .ws_xpixel = 0,
6- .ws_ypixel = 0,
7+ .ws_xpixel = size.xpixel,
8+ .ws_ypixel = size.ypixel,
9 };
10
11 var master_fd: c_int = undefined;
12@@ -978,8 +978,8 @@ const Daemon = struct {
13 var ws: cross.c.struct_winsize = .{
14 .ws_row = resize.rows,
15 .ws_col = resize.cols,
16- .ws_xpixel = 0,
17- .ws_ypixel = 0,
18+ .ws_xpixel = resize.xpixel,
19+ .ws_ypixel = resize.ypixel,
20 };
21 _ = cross.c.ioctl(pty_fd, cross.c.TIOCSWINSZ, &ws);
22 // Disable prompt_redraw before resize. The daemon's internal terminal
23@@ -1017,8 +1017,8 @@ const Daemon = struct {
24 var ws: cross.c.struct_winsize = .{
25 .ws_row = resize.rows,
26 .ws_col = resize.cols,
27- .ws_xpixel = 0,
28- .ws_ypixel = 0,
29+ .ws_xpixel = resize.xpixel,
30+ .ws_ypixel = resize.ypixel,
31 };
32 _ = cross.c.ioctl(pty_fd, cross.c.TIOCSWINSZ, &ws);
33 // Disable prompt_redraw before resize (same rationale as handleInit).