From d482bf0a304b8224499bf9de9e0781518106ec7c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 13 Mar 2020 18:44:23 +0100 Subject: sixel: improve handling of images when reflowing the grids Update the sixels' 'row' attribute when re-flowing a grid, to ensure it is rendered at the correct place. This should work in most cases, but will break when the cell size has changed (e.g. font size increase/decrease, or a DPI change). This patch also moves the sixel image list from the terminal struct into the grid struct. The sixels are per-grid after all. --- terminal.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 2a742268..35e145a7 100644 --- a/terminal.c +++ b/terminal.c @@ -721,8 +721,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, .start = {-1, -1}, .end = {-1, -1}, }, - .normal = {.damage = tll_init(), .scroll_damage = tll_init()}, - .alt = {.damage = tll_init(), .scroll_damage = tll_init()}, + .normal = {.damage = tll_init(), .scroll_damage = tll_init(), .sixel_images = tll_init()}, + .alt = {.damage = tll_init(), .scroll_damage = tll_init(), .sixel_images = tll_init()}, .grid = &term->normal, .meta = { .esc_prefix = true, @@ -747,7 +747,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, .sixel = { .palette_size = SIXEL_MAX_COLORS, }, - .sixel_images = tll_init(), .hold_at_exit = conf->hold_at_exit, .shutdown_cb = shutdown_cb, .shutdown_data = shutdown_data, @@ -978,9 +977,12 @@ term_destroy(struct terminal *term) tll_free(term->ptmx_buffer); tll_free(term->tab_stops); - tll_foreach(term->sixel_images, it) + tll_foreach(term->normal.sixel_images, it) sixel_destroy(&it->item); - tll_free(term->sixel_images); + tll_free(term->normal.sixel_images); + tll_foreach(term->alt.sixel_images, it) + sixel_destroy(&it->item); + tll_free(term->alt.sixel_images); free(term->foot_exe); free(term->cwd); @@ -1104,9 +1106,12 @@ term_reset(struct terminal *term, bool hard) term->meta.esc_prefix = true; term->meta.eight_bit = true; - tll_foreach(term->sixel_images, it) + tll_foreach(term->normal.sixel_images, it) + sixel_destroy(&it->item); + tll_free(term->normal.sixel_images); + tll_foreach(term->alt.sixel_images, it) sixel_destroy(&it->item); - tll_free(term->sixel_images); + tll_free(term->alt.sixel_images); if (!hard) return; -- cgit v1.3