Prefetch some information through xcb

This commit makes libxcb prefetch some information that will be needed
later anyway. This avoids some round-trips to the X11 server since the
information is already present when needed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2021-03-05 14:16:52 +01:00
parent 7da136dca4
commit bae1f4b354

View File

@ -24,6 +24,8 @@
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <xcb/xinerama.h>
#include <xcb/bigreq.h>
#ifdef I3_ASAN_ENABLED
#include <sanitizer/lsan_interface.h>
@ -573,6 +575,14 @@ int main(int argc, char *argv[]) {
root_screen = xcb_aux_get_screen(conn, conn_screen);
root = root_screen->root;
/* Prefetch X11 extensions that we are interested in. */
xcb_prefetch_extension_data(conn, &xcb_xkb_id);
xcb_prefetch_extension_data(conn, &xcb_xinerama_id);
xcb_prefetch_extension_data(conn, &xcb_randr_id);
xcb_prefetch_extension_data(conn, &xcb_shape_id);
/* BIG-REQUESTS is used by libxcb internally. */
xcb_prefetch_extension_data(conn, &xcb_big_requests_id);
/* Place requests for the atoms we need as soon as possible */
#define xmacro(atom) \
xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom);
@ -602,6 +612,8 @@ int main(int argc, char *argv[]) {
visual_type = get_visualtype(root_screen);
}
xcb_prefetch_maximum_request_length(conn);
init_dpi();
DLOG("root_depth = %d, visual_id = 0x%08x.\n", root_depth, visual_type->visual_id);
@ -666,9 +678,6 @@ int main(int argc, char *argv[]) {
xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER);
const xcb_query_extension_reply_t *extreply;
xcb_prefetch_extension_data(conn, &xcb_xkb_id);
xcb_prefetch_extension_data(conn, &xcb_shape_id);
extreply = xcb_get_extension_data(conn, &xcb_xkb_id);
xkb_supported = extreply->present;
if (!extreply->present) {