xcb-client-helper: Call xcb_wait_for_event directly

We're currently calling ppoll() before calling xcb_wait_for_event(), which
may be due to initially trying to make this non-blocking.

However, xcb_wait_for_event() reads all events available - even if there
are more than one.

There are a handful of X properties we're sent that we don't explicitly
ask for, and if these end up in the same read, we could theoretically
end up in a poll() with nothing coming in.

Drop the extra ppoll() and just let xcb_wait_for_event() do the blocking
for us.

I'm hoping this fixes the occasional timeout in the xwayland test, but
it's a reasonable code simplification even if it doesn't.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2024-04-11 10:06:56 -05:00
parent 2d3cca3d3e
commit 56d3ea128a
1 changed files with 1 additions and 18 deletions

View File

@ -380,23 +380,6 @@ window_x11_unmap(struct window_x11 *window)
xcb_flush(window->conn->connection);
}
static xcb_generic_event_t *
poll_for_event(xcb_connection_t *conn)
{
int fd = xcb_get_file_descriptor(conn);
struct pollfd pollfds = {};
int rpol;
pollfds.fd = fd;
pollfds.events = POLLIN;
rpol = ppoll(&pollfds, 1, NULL, NULL);
if (rpol > 0 && (pollfds.revents & POLLIN))
return xcb_wait_for_event(conn);
return NULL;
}
static void
window_x11_set_cursor(struct window_x11 *window, const char *cursor_name)
{
@ -478,7 +461,7 @@ handle_events_x11(struct window_x11 *window)
break;
}
ev = poll_for_event(window->conn->connection);
ev = xcb_wait_for_event(window->conn->connection);
if (!ev) {
fprintf(stderr, "Error, no event received, "
"although we requested for one!\n");