From da48bb6709b83b2cc7ba4aa370fb4ef0daf24ae7 Mon Sep 17 00:00:00 2001 From: Shreesh Adiga <16567adigashreesh@gmail.com> Date: Wed, 2 Dec 2020 11:05:39 +0200 Subject: vo_sixel: re-fit image on terminal resize The obvious approach would be SIGWINCH, however, integrating it would be tricky, so instead we simply poll the size on draw_frame. This means the image won't resize automatically when still - e.g. cover art or when paused, though it would re-fit on OSD changes. --- video/out/vo_sixel.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/video/out/vo_sixel.c b/video/out/vo_sixel.c index 961e531ce3..627e69f81a 100644 --- a/video/out/vo_sixel.c +++ b/video/out/vo_sixel.c @@ -346,7 +346,26 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) SIXELSTATUS status; struct mp_image *mpi = NULL; - if (frame->repeat && !frame->redraw) { + int prev_rows = priv->num_rows; + int prev_cols = priv->num_cols; + int prev_height = vo->dheight; + int prev_width = vo->dwidth; + bool resized = false; + update_canvas_dimensions(vo); + + if (prev_rows != priv->num_rows || prev_cols != priv->num_cols || + prev_width != vo->dwidth || prev_height != vo->dheight) + { + set_sixel_output_parameters(vo); + // Not checking for vo->config_ok because draw_frame is never called + // with a failed reconfig. + update_sixel_swscaler(vo, vo->params); + + printf(ESC_CLEAR_SCREEN); + resized = true; + } + + if (frame->repeat && !frame->redraw && !resized) { // Frame is repeated, and no need to update OSD either priv->skip_frame_draw = true; return; -- cgit v1.2.3