diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 6d9e24354..cd41d32cc 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -571,12 +571,13 @@ int kitty_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ return -1; } //fprintf(stderr, "FROM: %d/%d state: %d s->n: %p\n", s->movedfromy, s->movedfromx, s->invalidated, s->n); + const ncplane* stdn = notcurses_stdplane_const(nc); for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){ for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){ - struct crender *r = &p->crender[yy * p->dimx + xx]; + const int ridx = (yy - stdn->absy) * p->dimx + (xx - stdn->absx); + struct crender *r = &p->crender[ridx]; if(!r->sprixel){ if(s->n){ - const ncplane* stdn = notcurses_stdplane_const(nc); //fprintf(stderr, "CHECKING %d/%d\n", yy - s->movedfromy, xx - s->movedfromx); sprixcell_e state = sprixel_state(s, yy - s->movedfromy + s->n->absy - stdn->absy, xx - s->movedfromx + s->n->absx - stdn->absx); diff --git a/src/lib/sixel.c b/src/lib/sixel.c index 778339063..ee24f000b 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -693,9 +693,11 @@ int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ (void)out; int starty = s->movedfromy; int startx = s->movedfromx; + const ncplane* stdn = notcurses_stdplane_const(nc); for(int yy = starty ; yy < starty + s->dimy && yy < p->dimy ; ++yy){ for(int xx = startx ; xx < startx + s->dimx && xx < p->dimx ; ++xx){ - struct crender *r = &p->crender[yy * p->dimx + xx]; + int ridx = (yy - stdn->absy) * p->dimx + (xx - stdn->absx); + struct crender *r = &p->crender[ridx]; // FIXME this probably overdoes it -- look at kitty_destroy() if(!r->sprixel){ r->s.damaged = 1;