xkb_x11_keymap_new_from_device: Less X11 round-trips
authorUli Schlachter <psychon@znc.in>
Sun, 7 Mar 2021 06:42:28 +0000 (07:42 +0100)
committerRan Benita <ran@unusedvar.com>
Tue, 9 Mar 2021 09:00:13 +0000 (11:00 +0200)
commit40c00b472144d1684d2fb97cafef39ef59f21b28
treea7d8ad463ed4831a806d6548bb4b388e28c0caad
parent82a5bdc43c7bd942b20b1ecf453db980d0a75530
xkb_x11_keymap_new_from_device: Less X11 round-trips

On my system, calling xkb_x11_keymap_new_from_device() did 78 round trips to the
X11 server, which seems excessive. This commit brings this number down to about
9 to 10 round trips.

The existing functions adopt_atom() and adopt_atoms() guarantee that the atom
was adopted by the time they return. Thus, each call to these functions must do
a round-trip. However, none of the callers need this guarantee.

This commit makes "atom adopting" asynchronous: Only some time later is the atom
actually adopted. Until then, it is in some pending "limbo" state.

This actually fixes a TODO in the comments.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/216
Signed-off-by: Uli Schlachter <psychon@znc.in>
src/x11/keymap.c
src/x11/util.c
src/x11/x11-priv.h