XCB 函数从客户端队列中丢弃事件(等效于 XSync(..., True))

XCB function to discard events from client queue (XSync(..., True) equivalent)

在 Xlib 中,有 XSync,据我了解,如果 discard 参数为 True.

XCB中是否有对应的功能?

我发现 xcb_aux_sync mentioned as such an equivalent, but I'm not sure how accurate this is and whether it applies to all events: Its definition seems to corroborate that it's "equivalent to calling XGetInputFocus() and throwing away the reply" as mentioned in the previous source, but XGetInputFocus's manpage 只提到丢弃 keyboard 事件,而不是整个队列中的所有事件。

discard all events currently in the client's event queue

您可以向 libxcb 询问下一个排队的事件,然后将其删除。循环重复,直到队列为空。

xcb_generic_event_t *event;
do {
  event = xcb_poll_for_queued_event(c);
  free(event);
} while (event != NULL);

我不确定 XSync 到底在做什么,但以上至少应该回答了你问题的这一部分。