File U_0004-poll_for_event-Allow-using-xcb_poll_for_queued_event.patch of Package libX11.26493
From 823a0f8a820247b6c1e092f679b49cbdc2ea5c95 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daenzer@amd.com>
Date: Fri, 28 Sep 2018 17:24:17 +0200
Subject: [PATCH 4/6] poll_for_event: Allow using xcb_poll_for_queued_event
It avoids reading from the display connection again in cases where that
was already done.
Suggested-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Uli Schlachter <psychon@znc.in>
---
src/xcb_io.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/xcb_io.c b/src/xcb_io.c
index a32b7d75..6a12d150 100644
--- a/src/xcb_io.c
+++ b/src/xcb_io.c
@@ -230,7 +230,7 @@ static void widen(uint64_t *wide, unsigned int narrow)
* variable for that thread to process the response and wake us up.
*/
-static xcb_generic_reply_t *poll_for_event(Display *dpy)
+static xcb_generic_reply_t *poll_for_event(Display *dpy, Bool queued_only)
{
/* Make sure the Display's sequence numbers are valid */
require_socket(dpy);
@@ -238,8 +238,12 @@ static xcb_generic_reply_t *poll_for_event(Display *dpy)
/* Precondition: This thread can safely get events from XCB. */
assert(dpy->xcb->event_owner == XlibOwnsEventQueue && !dpy->xcb->event_waiter);
- if(!dpy->xcb->next_event)
- dpy->xcb->next_event = xcb_poll_for_event(dpy->xcb->connection);
+ if(!dpy->xcb->next_event) {
+ if(queued_only)
+ dpy->xcb->next_event = xcb_poll_for_queued_event(dpy->xcb->connection);
+ else
+ dpy->xcb->next_event = xcb_poll_for_event(dpy->xcb->connection);
+ }
if(dpy->xcb->next_event)
{
@@ -271,7 +275,7 @@ static xcb_generic_reply_t *poll_for_response(Display *dpy)
void *response;
xcb_generic_error_t *error;
PendingRequest *req;
- while(!(response = poll_for_event(dpy)) &&
+ while(!(response = poll_for_event(dpy, False)) &&
(req = dpy->xcb->pending_requests) &&
!req->reply_waiter)
{
@@ -281,7 +285,7 @@ static xcb_generic_reply_t *poll_for_response(Display *dpy)
&response, &error)) {
/* xcb_poll_for_reply64 may have read events even if
* there is no reply. */
- response = poll_for_event(dpy);
+ response = poll_for_event(dpy, True);
break;
}
@@ -626,7 +630,7 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
{ /* need braces around ConditionWait */
ConditionWait(dpy, dpy->xcb->event_notify);
}
- while((event = poll_for_event(dpy)))
+ while((event = poll_for_event(dpy, True)))
handle_response(dpy, event, True);
}
--
2.16.4