From 3b9e8287fd4c1096a2d6244aa07bc28cacb4da8d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 15 Mar 2020 18:19:15 +0100 Subject: X11: Factor out flushing pending exposures --- pugl/detail/x11.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index 7edc1ed..780213d 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -741,6 +741,27 @@ handleSelectionRequest(const PuglWorld* world, XSendEvent(world->impl->display, note.requestor, True, 0, (XEvent*)¬e); } +/// Flush pending configure and expose events for all views +static void +flushExposures(PuglWorld* world) +{ + for (size_t i = 0; i < world->numViews; ++i) { + PuglView* const view = world->views[i]; + PuglEvent* const configure = &view->impl->pendingConfigure; + PuglEvent* const expose = &view->impl->pendingExpose; + + if (configure->type || expose->type) { + view->backend->enter(view, expose->type ? &expose->expose : NULL); + view->eventFunc(view, configure); + view->eventFunc(view, expose); + view->backend->leave(view, expose->type ? &expose->expose : NULL); + + configure->type = 0; + expose->type = 0; + } + } +} + PuglStatus puglDispatchEvents(PuglWorld* world) { @@ -806,22 +827,7 @@ puglDispatchEvents(PuglWorld* world) } } - // Flush pending configure and expose events for all views - for (size_t i = 0; i < world->numViews; ++i) { - PuglView* const view = world->views[i]; - PuglEvent* const configure = &view->impl->pendingConfigure; - PuglEvent* const expose = &view->impl->pendingExpose; - - if (configure->type || expose->type) { - view->backend->enter(view, expose->type ? &expose->expose : NULL); - view->eventFunc(view, configure); - view->eventFunc(view, expose); - view->backend->leave(view, expose->type ? &expose->expose : NULL); - - configure->type = 0; - expose->type = 0; - } - } + flushExposures(world); world->impl->dispatchingEvents = false; -- cgit v1.2.1