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.
This commit is contained in:
Daniel Eklöf 2020-03-13 18:44:23 +01:00
parent 62a5805d4b
commit d482bf0a30
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 69 additions and 42 deletions

View file

@ -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->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);
if (!hard)
return;