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.
(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))))