aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/x11.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-02-02 14:40:56 +0100
committerDavid Robillard <d@drobilla.net>2020-02-02 14:41:51 +0100
commit0f114d846286355c90df02ef45e9c7e098b71104 (patch)
tree19d909ca32dc48a43a968374b17270f8cd8be017 /pugl/detail/x11.c
parentfe0a68d8ebcc52b80ed91fab073f09dcfb7911fa (diff)
downloadpugl-0f114d846286355c90df02ef45e9c7e098b71104.tar.gz
pugl-0f114d846286355c90df02ef45e9c7e098b71104.tar.bz2
pugl-0f114d846286355c90df02ef45e9c7e098b71104.zip
X11: Dispatch exposures from event callbacks in the same iteration
Diffstat (limited to 'pugl/detail/x11.c')
-rw-r--r--pugl/detail/x11.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index bbf4307..49c843b 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -671,6 +671,8 @@ puglDispatchEvents(PuglWorld* world)
Display* display = world->impl->display;
XFlush(display);
+ world->impl->dispatchingEvents = true;
+
// Process all queued events (locally, without flushing or reading)
while (XEventsQueued(display, QueuedAlready) > 0) {
XEvent xevent;
@@ -783,6 +785,8 @@ puglDispatchEvents(PuglWorld* world)
}
}
+ world->impl->dispatchingEvents = false;
+
return PUGL_SUCCESS;
}
@@ -811,7 +815,15 @@ puglPostRedisplay(PuglView* view)
PuglStatus
puglPostRedisplayRect(PuglView* view, PuglRect rect)
{
- if (view->visible) {
+ if (view->world->impl->dispatchingEvents) {
+ // Currently dispatching events, add/expand expose for the loop end
+ const PuglEventExpose event = {
+ PUGL_EXPOSE, 0, rect.x, rect.y, rect.width, rect.height, 0
+ };
+
+ addPendingExpose(view, (const PuglEvent*)&event);
+ } else if (view->visible) {
+ // Not dispatching events, send an X expose so we wake up next time
const int x = (int)floor(rect.x);
const int y = (int)floor(rect.y);
const int w = (int)ceil(rect.x + rect.width) - x;