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.
This commit is contained in:
Shreesh Adiga 2020-12-02 11:05:39 +02:00 committed by avih
parent 3fd656ee7b
commit da48bb6709
1 changed files with 20 additions and 1 deletions

View File

@ -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;