From 5a6fefb427bd78f27c8d530974c03cccaa4cfef9 Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Mon, 17 Aug 2026 08:48:08 +0100 Subject: [PATCH] image: simplify geometry cleanup --- image-sixel.c | 7 ------- image.c | 10 ++++------ tmux.h | 3 +-- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/image-sixel.c b/image-sixel.c index 079275b99..ade20c58a 100644 --- a/image-sixel.c +++ b/image-sixel.c @@ -1307,13 +1307,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 xpixel, u_int ypixel) diff --git a/image.c b/image.c index 90ed3d56a..8be9e39dc 100644 --- a/image.c +++ b/image.c @@ -88,16 +88,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_fallback = { - "fallback", IMAGE_BACKEND_SCROLLS, NULL, NULL, NULL + "fallback", 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 }; /* Find the image backend supported by a terminal. */ @@ -141,8 +139,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. */ diff --git a/tmux.h b/tmux.h index 28a658ce6..0c7665eca 100644 --- a/tmux.h +++ b/tmux.h @@ -4295,9 +4295,8 @@ void image_get_fallback_cell(struct tty *, struct image *, u_int, /* 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); void sixel_free(struct sixel_image *); void sixel_log(struct sixel_image *);