From bfdd5dd01d1183d4497c0a03f87f2e7f357c0336 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 16 Sep 2021 00:03:57 -0400 Subject: [PATCH 1/2] notcurses_input: need lock around refresh() --- src/input/input.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/input/input.cpp b/src/input/input.cpp index b53faf522..934c6002e 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -34,7 +34,9 @@ static struct ncuplot* plot; const char* nckeystr(char32_t spkey){ switch(spkey){ // FIXME case NCKEY_RESIZE: + mtx.lock(); NotCurses::get_instance().refresh(&dimy, &dimx); + mtx.unlock(); return "resize event"; case NCKEY_INVALID: return "invalid"; case NCKEY_LEFT: return "left"; From 5a64f25ac2fca1c2f67b24e40f0598ec11ffc9e4 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 16 Sep 2021 00:07:47 -0400 Subject: [PATCH 2/2] restripe_lastframe: properly index into tmp/lastframe --- src/lib/render.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/render.c b/src/lib/render.c index 34d275776..ea1dd627c 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -4,6 +4,10 @@ #include #include "internal.h" +// update for a new visual area of |rows|x|cols|, neither of which may be zero. +// copies that area of the lastframe (damage map) which is shared between the +// two. new areas are initialized to empty, just like a new plane. lost areas +// have their egcpool entries purged. static nccell* restripe_lastframe(notcurses* nc, int rows, int cols){ assert(rows); @@ -13,7 +17,8 @@ restripe_lastframe(notcurses* nc, int rows, int cols){ if(tmp == NULL){ return NULL; } - size_t maxlinecopy = sizeof(nccell) * (nc->lfdimx > cols ? cols : nc->lfdimx); + size_t copycols = nc->lfdimx > cols ? cols : nc->lfdimx; + size_t maxlinecopy = sizeof(nccell) * copycols; size_t minlineset = sizeof(nccell) * cols - maxlinecopy; unsigned zorch = nc->lfdimx > cols ? nc->lfdimx - cols : 0; for(int y = 0 ; y < rows ; ++y){ @@ -22,11 +27,11 @@ restripe_lastframe(notcurses* nc, int rows, int cols){ memcpy(&tmp[cols * y], &nc->lastframe[nc->lfdimx * y], maxlinecopy); } if(minlineset){ - memset(&tmp[cols * y + maxlinecopy / sizeof(nccell)], 0, minlineset); + memset(&tmp[cols * y + copycols], 0, minlineset); } // excise any egcpool entries from the right of the new plane area if(zorch){ - for(unsigned x = maxlinecopy ; x < maxlinecopy + zorch ; ++x){ + for(unsigned x = copycols ; x < copycols + zorch ; ++x){ pool_release(&nc->pool, &nc->lastframe[fbcellidx(y, nc->lfdimx, x)]); } }