From 6a77f96642b201f614ce7eb67f3b6ec4e1e8c181 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 26 Jul 2019 23:46:29 +0200 Subject: Make enterContext take a drawing parameter like leaveContext These need to be symmetric because sometimes different things need to happen in either situation when entering the context as well. --- pugl/pugl_x11.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'pugl/pugl_x11.c') diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index ff44aef..3a0f4c2 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -68,15 +68,15 @@ puglInitInternals(void) } void -puglEnterContext(PuglView* view) +puglEnterContext(PuglView* view, bool drawing) { - view->impl->backend->enter(view); + view->impl->backend->enter(view, drawing); } void -puglLeaveContext(PuglView* view, bool flush) +puglLeaveContext(PuglView* view, bool drawing) { - view->impl->backend->leave(view, flush); + view->impl->backend->leave(view, drawing); } int @@ -559,7 +559,9 @@ puglProcessEvents(PuglView* view) } if (config_event.type || expose_event.type) { - puglEnterContext(view); + const bool draw = expose_event.type && expose_event.expose.count == 0; + + puglEnterContext(view, draw); if (config_event.type) { view->width = (int)config_event.configure.width; @@ -568,12 +570,11 @@ puglProcessEvents(PuglView* view) view->eventFunc(view, (const PuglEvent*)&config_event); } - if (expose_event.type && expose_event.expose.count == 0) { + if (draw) { view->eventFunc(view, (const PuglEvent*)&expose_event); - puglLeaveContext(view, true); - } else { - puglLeaveContext(view, false); } + + puglLeaveContext(view, draw); } return PUGL_SUCCESS; -- cgit v1.2.1