image: simplify geometry cleanup

This commit is contained in:
Michael Grant
2026-08-17 08:47:16 +01:00
parent 7bd1ba9cad
commit 073dc4c3dd
3 changed files with 5 additions and 15 deletions

View File

@@ -1349,13 +1349,6 @@ sixel_free_output(struct tty *tty, __unused int send)
tty->image_data = NULL;
}
/* Discard SIXEL output state after a terminal geometry change. */
void
sixel_geometry_changed(struct tty *tty)
{
sixel_free_output(tty, !!(tty->flags & TTY_OPENED));
}
/* Render an image at a terminal's current pixel geometry. */
static struct sixel_image *
sixel_render_image(struct image *im, u_int cell_w, u_int cell_h)

10
image.c
View File

@@ -87,16 +87,14 @@ struct image_backend {
void (*draw_rect)(struct tty *,
const struct image_rect *, const struct tty_style_ctx *);
void (*free)(struct tty *, int);
void (*geometry_changed)(struct tty *);
};
static const struct image_backend image_backend_ascii = {
"ascii", IMAGE_BACKEND_SCROLLS, NULL, NULL, NULL
"ascii", IMAGE_BACKEND_SCROLLS, NULL, NULL
};
static const struct image_backend image_backend_sixel = {
"sixel", IMAGE_BACKEND_GRAPHICAL|IMAGE_BACKEND_TEMPORAL,
sixel_draw_rect,
sixel_free_output, sixel_geometry_changed
sixel_draw_rect, sixel_free_output
};
/* Compare images by server ID. */
@@ -152,8 +150,8 @@ void
image_tty_geometry_changed(struct tty *tty)
{
image_tty_update(tty);
if (tty->image_backend->geometry_changed != NULL)
tty->image_backend->geometry_changed(tty);
if (tty->image_backend->free != NULL)
tty->image_backend->free(tty, !!(tty->flags & TTY_OPENED));
}
/* Free image backend state for a terminal. */

3
tmux.h
View File

@@ -4259,9 +4259,8 @@ void image_rect_get_coords(const struct image_rect *,
/* image-sixel.c */
#define SIXEL_COLOUR_REGISTERS 1024
void sixel_draw_rect(struct tty *,
const struct image_rect *, const struct tty_style_ctx *);
const struct image_rect *, const struct tty_style_ctx *);
void sixel_free_output(struct tty *, int);
void sixel_geometry_changed(struct tty *);
struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int, u_int,
u_int);
void sixel_free(struct sixel_image *);