aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-08-03 22:52:42 +0200
committerDavid Robillard <d@drobilla.net>2019-09-03 08:34:39 +0200
commit2a0287b0db5bdde4e8b9de91ddc560233e1ee343 (patch)
tree24c08b197c84f7dfbec2db703d6e6288a05d850d
parent2d19fe6798a900aec59657bfc5eded66f8f798d5 (diff)
downloadpugl-2a0287b0db5bdde4e8b9de91ddc560233e1ee343.tar.gz
pugl-2a0287b0db5bdde4e8b9de91ddc560233e1ee343.tar.bz2
pugl-2a0287b0db5bdde4e8b9de91ddc560233e1ee343.zip
X11: Improve puglPostRedisplay() performance
-rw-r--r--pugl/detail/x11.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index e7b39f8..1f2a471 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -573,9 +573,27 @@ merge_expose_events(PuglEvent* dst, const PuglEvent* src)
}
}
+static void
+sendRedisplayEvent(PuglView* view)
+{
+ XExposeEvent ev = { Expose, 0, True, view->impl->display, view->impl->win,
+ 0, 0, (int)view->frame.width, (int)view->frame.height,
+ 0 };
+
+ XSendEvent(view->impl->display, view->impl->win, False, 0, (XEvent*)&ev);
+}
+
PUGL_API PuglStatus
puglDispatchEvents(PuglWorld* world)
{
+ // Send expose events for any views with pending redisplays
+ for (size_t i = 0; i < world->numViews; ++i) {
+ if (world->views[i]->redisplay) {
+ sendRedisplayEvent(world->views[i]);
+ world->views[i]->redisplay = false;
+ }
+ }
+
// Flush just once at the start to fill event queue
Display* display = world->impl->display;
XFlush(display);
@@ -673,13 +691,7 @@ puglGetTime(const PuglWorld* world)
void
puglPostRedisplay(PuglView* view)
{
- XExposeEvent ev = {Expose, 0, True,
- view->impl->display, view->impl->win,
- 0, 0,
- view->frame.width, view->frame.height,
- 0};
-
- XSendEvent(view->impl->display, view->impl->win, False, 0, (XEvent*)&ev);
+ view->redisplay = true;
}
PuglNativeWindow