From c34646cdfa3184920e12186865063f631d9a4408 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 28 Aug 2012 04:26:04 +0000 Subject: [PATCH] Ask Xlib for events before blocking on the display in x11graph.scm. Fixes race whereby Xlib may have queued up events already before we ask the OS about I/O on the underlying file descriptor. This can cause us to fail to notice an event until a second one comes along, so that, e.g., a newly created window will hang until you move the mouse over it or similar. --- src/runtime/x11graph.scm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/runtime/x11graph.scm b/src/runtime/x11graph.scm index f273c898d..fd879179c 100644 --- a/src/runtime/x11graph.scm +++ b/src/runtime/x11graph.scm @@ -314,12 +314,13 @@ USA. (define (%read-and-process-event display) (let ((event - (and (eq? 'READ - (test-for-io-on-descriptor - (x-display-descriptor (x-display/xd display)) - #t - 'READ)) - (x-display-process-events (x-display/xd display) 1)))) + (or (x-display-process-events (x-display/xd display) 2) + (and (eq? 'READ + (test-for-io-on-descriptor + (x-display-descriptor (x-display/xd display)) + #t + 'READ)) + (x-display-process-events (x-display/xd display) 1))))) (if event (process-event display event)))) -- 2.25.1