... |
... |
@@ -230,7 +230,7 @@ static void widen(uint64_t *wide, unsigned int narrow) |
230
|
230
|
* variable for that thread to process the response and wake us up.
|
231
|
231
|
*/
|
232
|
232
|
|
233
|
|
-static xcb_generic_reply_t *poll_for_event(Display *dpy)
|
|
233
|
+static xcb_generic_reply_t *poll_for_event(Display *dpy, Bool queued_only)
|
234
|
234
|
{
|
235
|
235
|
/* Make sure the Display's sequence numbers are valid */
|
236
|
236
|
require_socket(dpy);
|
... |
... |
@@ -238,8 +238,12 @@ static xcb_generic_reply_t *poll_for_event(Display *dpy) |
238
|
238
|
/* Precondition: This thread can safely get events from XCB. */
|
239
|
239
|
assert(dpy->xcb->event_owner == XlibOwnsEventQueue && !dpy->xcb->event_waiter);
|
240
|
240
|
|
241
|
|
- if(!dpy->xcb->next_event)
|
242
|
|
- dpy->xcb->next_event = xcb_poll_for_event(dpy->xcb->connection);
|
|
241
|
+ if(!dpy->xcb->next_event) {
|
|
242
|
+ if(queued_only)
|
|
243
|
+ dpy->xcb->next_event = xcb_poll_for_queued_event(dpy->xcb->connection);
|
|
244
|
+ else
|
|
245
|
+ dpy->xcb->next_event = xcb_poll_for_event(dpy->xcb->connection);
|
|
246
|
+ }
|
243
|
247
|
|
244
|
248
|
if(dpy->xcb->next_event)
|
245
|
249
|
{
|
... |
... |
@@ -271,12 +275,21 @@ static xcb_generic_reply_t *poll_for_response(Display *dpy) |
271
|
275
|
void *response;
|
272
|
276
|
xcb_generic_error_t *error;
|
273
|
277
|
PendingRequest *req;
|
274
|
|
- while(!(response = poll_for_event(dpy)) &&
|
|
278
|
+ while(!(response = poll_for_event(dpy, False)) &&
|
275
|
279
|
(req = dpy->xcb->pending_requests) &&
|
276
|
|
- !req->reply_waiter &&
|
277
|
|
- xcb_poll_for_reply64(dpy->xcb->connection, req->sequence, &response, &error))
|
|
280
|
+ !req->reply_waiter)
|
278
|
281
|
{
|
279
|
|
- uint64_t request = X_DPY_GET_REQUEST(dpy);
|
|
282
|
+ uint64_t request;
|
|
283
|
+
|
|
284
|
+ if(!xcb_poll_for_reply64(dpy->xcb->connection, req->sequence,
|
|
285
|
+ &response, &error)) {
|
|
286
|
+ /* xcb_poll_for_reply64 may have read events even if
|
|
287
|
+ * there is no reply. */
|
|
288
|
+ response = poll_for_event(dpy, True);
|
|
289
|
+ break;
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ request = X_DPY_GET_REQUEST(dpy);
|
280
|
293
|
if(XLIB_SEQUENCE_COMPARE(req->sequence, >, request))
|
281
|
294
|
{
|
282
|
295
|
throw_thread_fail_assert("Unknown sequence number "
|
... |
... |
@@ -617,7 +630,7 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) |
617
|
630
|
{ /* need braces around ConditionWait */
|
618
|
631
|
ConditionWait(dpy, dpy->xcb->event_notify);
|
619
|
632
|
}
|
620
|
|
- while((event = poll_for_event(dpy)))
|
|
633
|
+ while((event = poll_for_event(dpy, True)))
|
621
|
634
|
handle_response(dpy, event, True);
|
622
|
635
|
}
|
623
|
636
|
|