From: Taylor R Campbell Date: Tue, 28 Aug 2012 04:26:04 +0000 (+0000) Subject: Ask Xlib for events before blocking on the display in x11graph.scm. X-Git-Tag: release-9.2.0~230 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=c34646cdfa3184920e12186865063f631d9a4408;p=mit-scheme.git 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. --- 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))))