Minor API cleanup.

This commit is contained in:
Scott Duensing 2026-03-18 00:06:24 -05:00
parent 6a4044d0d7
commit 73a54a8b3a
5 changed files with 20 additions and 31 deletions

View file

@ -189,23 +189,20 @@ int32_t appMain(DxeAppContextT *ctx) {
sWin->onClose = onClose; sWin->onClose = onClose;
sWin->onPaint = onPaint; sWin->onPaint = onPaint;
// Initial paint into content buffer // Initial paint — dvxInvalidateWindow calls onPaint automatically
RectT full = {0, 0, sWin->contentW, sWin->contentH};
onPaint(sWin, &full);
dvxInvalidateWindow(ac, sWin); dvxInvalidateWindow(ac, sWin);
// Main loop: check if the second has changed, repaint if so, then yield. // Main loop: check if the second has changed, repaint if so, then yield.
// tsYield() transfers control back to the shell's task scheduler. // tsYield() transfers control back to the shell's task scheduler.
// On a 486, time() resolution is 1 second, so we yield many times per // On a 486, time() resolution is 1 second, so we yield many times per
// second between actual updates — this keeps CPU usage near zero. // second between actual updates — this keeps CPU usage near zero.
// dvxInvalidateWindow marks the window dirty so the compositor will // dvxInvalidateWindow marks the window dirty and calls onPaint to
// flush it to the LFB on the next composite pass. // update the content buffer before the compositor flushes it.
while (!sState.quit) { while (!sState.quit) {
time_t now = time(NULL); time_t now = time(NULL);
if (now != sState.lastUpdate) { if (now != sState.lastUpdate) {
updateTime(); updateTime();
onPaint(sWin, &full);
dvxInvalidateWindow(ac, sWin); dvxInvalidateWindow(ac, sWin);
} }

View file

@ -1567,6 +1567,14 @@ void dvxInvalidateRect(AppContextT *ctx, WindowT *win, int32_t x, int32_t y, int
// ============================================================ // ============================================================
void dvxInvalidateWindow(AppContextT *ctx, WindowT *win) { void dvxInvalidateWindow(AppContextT *ctx, WindowT *win) {
// Call the window's paint callback to update the content buffer
// before marking the screen dirty. This means raw-paint apps only
// need to call dvxInvalidateWindow — onPaint fires automatically.
if (win->onPaint) {
RectT fullRect = {0, 0, win->contentW, win->contentH};
win->onPaint(win, &fullRect);
}
win->contentDirty = true; win->contentDirty = true;
dirtyListAdd(&ctx->dirty, win->x, win->y, win->w, win->h); dirtyListAdd(&ctx->dirty, win->x, win->y, win->w, win->h);
} }

View file

@ -663,18 +663,12 @@ void widgetOnScroll(WindowT *win, ScrollbarOrientE orient, int32_t value) {
(void)orient; (void)orient;
(void)value; (void)value;
// Repaint with new scroll position // Repaint with new scroll position — dvxInvalidateWindow calls onPaint
if (win->onPaint) { if (win->widgetRoot) {
RectT fullRect = {0, 0, win->contentW, win->contentH}; AppContextT *ctx = wgtGetContext(win->widgetRoot);
win->onPaint(win, &fullRect);
// Dirty the window content area on screen so compositor redraws it if (ctx) {
if (win->widgetRoot) { dvxInvalidateWindow(ctx, win);
AppContextT *ctx = wgtGetContext(win->widgetRoot);
if (ctx) {
dvxInvalidateWindow(ctx, win);
}
} }
} }
} }

View file

@ -389,13 +389,8 @@ void wgtInvalidate(WidgetT *w) {
widgetManageScrollbars(w->window, ctx); widgetManageScrollbars(w->window, ctx);
} }
// Repaint (use win->onPaint so custom paint handlers like dialogs work) // Dirty the window — dvxInvalidateWindow calls onPaint automatically
WindowT *win = w->window; dvxInvalidateWindow(ctx, w->window);
RectT fullRect = {0, 0, win->contentW, win->contentH};
win->onPaint(win, &fullRect);
// Dirty the window on screen
dvxInvalidateWindow(ctx, win);
} }
@ -424,11 +419,8 @@ void wgtInvalidatePaint(WidgetT *w) {
return; return;
} }
// Repaint without measure/layout (use win->onPaint so custom handlers work) // Dirty the window — dvxInvalidateWindow calls onPaint automatically
WindowT *win = w->window; dvxInvalidateWindow(ctx, w->window);
RectT fullRect = {0, 0, win->contentW, win->contentH};
win->onPaint(win, &fullRect);
dvxInvalidateWindow(ctx, win);
} }

View file

@ -319,8 +319,6 @@ void clearOtherSelections(WidgetT *except) {
} }
if (clearSelectionOnWidget(prev) && prevWin != except->window) { if (clearSelectionOnWidget(prev) && prevWin != except->window) {
RectT fullRect = {0, 0, prevWin->contentW, prevWin->contentH};
widgetOnPaint(prevWin, &fullRect);
dvxInvalidateWindow(ctx, prevWin); dvxInvalidateWindow(ctx, prevWin);
} }
} }