gwin: Prevent multiple redraws

See https://community.ugfx.io/topic/4782-the-screen-is-redrawn-more-than-once/#comment-13706
This commit is contained in:
Joel Bodenmann 2025-04-07 15:23:02 +02:00
parent bb88845622
commit 01373710b7
2 changed files with 9 additions and 0 deletions

View file

@ -34,6 +34,7 @@ FEATURE: LGDP4532 driver improvements.
FIX: Win32 Keyboard driver now retrieves lock key states on window activate
FEATURE: Add SSD1312 GDISP driver
FEATURE: Add CH1115 GDISP driver
FIX: Fix multiple redraws of windows (thanks to Sergey Kushnir)
*** Release 2.9 ***

View file

@ -749,6 +749,7 @@ static void WM_Delete(GHandle gh) {
static void WM_Redraw(GHandle gh) {
gU32 flags;
gU32 parents = 0; // Used to indicate whether the window (gh) has parent(s).
flags = gh->flags;
gh->flags &= ~(GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW|GWIN_FLG_PARENTREVEAL);
@ -790,6 +791,8 @@ static void WM_Redraw(GHandle gh) {
if (gh->parent) {
// Child redraw is done
parents++;
// Get the parent to redraw the area
gh = gh->parent;
@ -806,6 +809,11 @@ static void WM_Redraw(GHandle gh) {
// Clear the area to the background color
gdispGFillArea(gh->display, gh->x, gh->y, gh->width, gh->height, gwinGetDefaultBgColor());
#if GWIN_NEED_CONTAINERS
if (!parents)
return;
#endif
// Now loop over all windows looking for overlaps. Redraw them if they overlap the newly exposed area.
for(gx = gwinGetNextWindow(0); gx; gx = gwinGetNextWindow(gx)) {
if ((gx->flags & GWIN_FLG_SYSVISIBLE)