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/server.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/server.c')
| -rw-r--r-- | src/server.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/server.c b/src/server.c index 9bddd0d..498b83f 100644 --- a/src/server.c +++ b/src/server.c @@ -346,6 +346,14 @@ int server_run(const char *name, const char *const argv[], uint16_t cols, screen_resize(&s.screen, c, rr); app_resize(s.app, c, rr); } + /* The cell size arrived with it, from a client new enough to + * send one and a terminal willing to say. Zero means neither, + * and app_set_cell_px leaves the default standing. */ + if (m.len >= 8) { + uint16_t cw = (uint16_t)(m.data[4] << 8 | m.data[5]); + uint16_t ch = (uint16_t)(m.data[6] << 8 | m.data[7]); + app_set_cell_px(s.app, cw, ch); + } } s.screen.force_full = true; /* a fresh client knows nothing */ app_graphics_reset(s.app); /* including any image we had sent */ |
