From 4693e9ac0b6792e8a6d2af2e46499158bf6b2509 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Sun, 15 Mar 2020 14:33:12 +0100
Subject: X11: Read from server if necessary in puglDispatchEvents()

This reduces input lag.  The previous approach was an over-optimization: what's
important here is to keep the iteration bounded by not continually flushing,
but we do want to read everything to be as up to date as possible.
---
 pugl/detail/x11.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index 7b83b38..4747f64 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -744,14 +744,14 @@ puglDispatchEvents(PuglWorld* world)
 {
 	const PuglX11Atoms* const atoms = &world->impl->atoms;
 
-	// Flush just once at the start to fill event queue
+	// Flush output to the server once at the start
 	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) {
+	// Process all queued events (without further flushing)
+	while (XEventsQueued(display, QueuedAfterReading) > 0) {
 		XEvent xevent;
 		XNextEvent(display, &xevent);
 
-- 
cgit v1.2.1