From 4cdb95b63f4e357321765c1418ade7f4e9bc0ed3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 12 May 2023 14:38:49 -0400 Subject: X11: Avoid deferring empty exposures --- src/internal.c | 12 ++---------- src/internal.h | 5 ----- src/x11.c | 23 +++++++++++++---------- 3 files changed, 15 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/internal.c b/src/internal.c index ca705a3..d9f034e 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1,4 +1,4 @@ -// Copyright 2012-2022 David Robillard +// Copyright 2012-2023 David Robillard // SPDX-License-Identifier: ISC #include "internal.h" @@ -169,14 +169,6 @@ puglConfigure(PuglView* view, const PuglEvent* event) return st; } -PuglStatus -puglExpose(PuglView* view, const PuglEvent* event) -{ - return (event->expose.width > 0.0 && event->expose.height > 0.0) - ? view->eventFunc(view, event) - : PUGL_SUCCESS; -} - PuglStatus puglDispatchEvent(PuglView* view, const PuglEvent* event) { @@ -220,7 +212,7 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) case PUGL_EXPOSE: assert(view->stage == PUGL_VIEW_STAGE_CONFIGURED); if (!(st0 = view->backend->enter(view, &event->expose))) { - st0 = puglExpose(view, event); + st0 = view->eventFunc(view, event); st1 = view->backend->leave(view, &event->expose); } break; diff --git a/src/internal.h b/src/internal.h index f30532b..0c6f448 100644 --- a/src/internal.h +++ b/src/internal.h @@ -51,11 +51,6 @@ PUGL_WARN_UNUSED_RESULT PuglStatus puglConfigure(PuglView* view, const PuglEvent* event); -/// Process expose event while already in the graphics context -PUGL_WARN_UNUSED_RESULT -PuglStatus -puglExpose(PuglView* view, const PuglEvent* event); - /// Dispatch `event` to `view`, entering graphics context if necessary PuglStatus puglDispatchEvent(PuglView* view, const PuglEvent* event); diff --git a/src/x11.c b/src/x11.c index 0a2096d..a5b0389 100644 --- a/src/x11.c +++ b/src/x11.c @@ -1514,7 +1514,9 @@ static void mergeExposeEvents(PuglExposeEvent* const dst, const PuglExposeEvent* const src) { if (!dst->type) { - *dst = *src; + if (src->width > 0.0 && src->height > 0.0) { + *dst = *src; + } } else { const int dst_r = dst->x + dst->width; const int src_r = src->x + src->width; @@ -1689,20 +1691,21 @@ flushExposures(PuglWorld* const world) view->impl->pendingConfigure.type = PUGL_NOTHING; view->impl->pendingExpose.type = PUGL_NOTHING; - if (expose.type) { - if (!(st0 = view->backend->enter(view, &expose.expose))) { + if (expose.type || configure.type) { + const PuglExposeEvent* const exposeEvent = + expose.type ? &expose.expose : NULL; + + if (!(st0 = view->backend->enter(view, exposeEvent))) { if (configure.type) { st0 = puglConfigure(view, &configure); } - st1 = puglExpose(view, &expose); - st2 = view->backend->leave(view, &expose.expose); - } - } else if (configure.type) { - if (!(st0 = view->backend->enter(view, NULL))) { - st0 = puglConfigure(view, &configure); - st1 = view->backend->leave(view, NULL); + if (expose.type) { + st1 = view->eventFunc(view, &expose); + } } + + st2 = view->backend->leave(view, exposeEvent); } } -- cgit v1.2.1