diff options
| author | user <user@clank> | 2026-08-14 23:13:56 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-14 23:13:56 +0200 |
| commit | 4b380e9b4cbd24dca99bef4991541aa1aece847f (patch) | |
| tree | fcd41dfdf23f17027523336dbe448ee683e72c16 /src/cmd.c | |
| parent | vendor: keep kitty images across a screen clear (diff) | |
| download | slosh-4b380e9b4cbd24dca99bef4991541aa1aece847f.tar.gz slosh-4b380e9b4cbd24dca99bef4991541aa1aece847f.tar.xz slosh-4b380e9b4cbd24dca99bef4991541aa1aece847f.zip | |
sl0ppty: carry the terminal's cell size, so images can have a size
"Kitty graphics pass through" was true of the tests and not of anything else.
Every test transmitted and placed in one command with explicit c=/r=; real
programs upload once with `a=t` and place per frame with `a=p`, saying
nothing about cells, and that path was broken from end to end.
A placement that does not say how many cells it covers is sized from the
image's pixels and the cell size. We never had a cell size:
- pty_spawn and pty_resize left ws_xpixel/ws_ypixel at zero, so a program
asking its own tty how big a cell is got nothing and fell back to guessing;
- ghostty_terminal_resize was called with 0, 0 for the cell size, so lib-vt
computed zero cells for such a placement -- and a placement covering zero
cells is skipped, which on screen is an image that simply is not there.
So the size now runs the whole way through. The client reads it from
TIOCGWINSZ (re-read on every resize, because a window can move to a monitor
with different metrics), MSG_HELLO and MSG_RESIZE carry it -- a 4-byte
payload still means "I did not say", so an older client still attaches -- the
app hands it to every pane in every tab, and each pane gives it to both its
pty and its terminal.
Where nobody knows, the default is 8x16 rather than 0. That is the whole
lesson of this bug: a plausible cell size means an image appears at roughly
the right size, and a zero means it does not appear at all.
`{"cmd":"resize"}` takes optional cell_w/cell_h, so a script can be a client
that knows its own metrics, and so the tests can be one.
The tests now use the protocol the way programs use it, including a check
that a program can read real pixel dimensions out of its own pty -- the thing
that was silently zero. The remaining half of the fix is one layer down, in
vendor/patches/0001.
Diffstat (limited to 'src/cmd.c')
| -rw-r--r-- | src/cmd.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -127,6 +127,12 @@ static char *cmd_json(app_t *a, screen_t *s, input_parser_t *in, if (!c || !r) return jerr("bad size"); screen_resize(s, c, r); app_resize(a, c, r); + /* The cell size in pixels, which a real client reports when it attaches. + * Here so that a script -- and the test suite -- can be a client that + * knows its own metrics, since images are sized against these. */ + uint16_t cw = (uint16_t)jv_geti(req, "cell_w", 0); + uint16_t ch = (uint16_t)jv_geti(req, "cell_h", 0); + app_set_cell_px(a, cw, ch); return jok_int(NULL, 0); } if (strcmp(cmd, "split") == 0) { |
