diff options
author | David Robillard <d@drobilla.net> | 2019-08-03 22:52:42 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-03 08:34:39 +0200 |
commit | 2a0287b0db5bdde4e8b9de91ddc560233e1ee343 (patch) | |
tree | 24c08b197c84f7dfbec2db703d6e6288a05d850d | |
parent | 2d19fe6798a900aec59657bfc5eded66f8f798d5 (diff) |
X11: Improve puglPostRedisplay() performance
-rw-r--r-- | pugl/detail/x11.c | 26 |
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 |