summaryrefslogtreecommitdiff
path: root/src/x11/util.c
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2021-03-07 08:01:49 +0100
committerRan Benita <ran@unusedvar.com>2021-03-09 11:00:13 +0200
commitb9707c1db094b601ba23f1fcf5e77ec7b53676b7 (patch)
tree5d474073d8ab36701ab2dfcd31468412fe004bfb /src/x11/util.c
parent40c00b472144d1684d2fb97cafef39ef59f21b28 (diff)
downloadxorg-lib-libxkbcommon-b9707c1db094b601ba23f1fcf5e77ec7b53676b7.tar.gz
Save three more round trips in xkb_x11_keymap_new_from_device()
Instead of asking for an atom name and waiting for the reply four times, this now sends four GetAtomName requests and waits for all the replies at once. Thus, this saves three round trips. Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src/x11/util.c')
-rw-r--r--src/x11/util.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/x11/util.c b/src/x11/util.c
index 766e9a0..6618dfe 100644
--- a/src/x11/util.c
+++ b/src/x11/util.c
@@ -124,20 +124,31 @@ xkb_x11_get_core_keyboard_device_id(xcb_connection_t *conn)
return device_id;
}
+void
+get_atom_name(xcb_connection_t *conn, xcb_atom_t atom,
+ xcb_get_atom_name_cookie_t *cookie)
+{
+ if (atom == 0) {
+ cookie->sequence = 0;
+ } else {
+ *cookie = xcb_get_atom_name(conn, atom);
+ }
+}
+
bool
-get_atom_name(xcb_connection_t *conn, xcb_atom_t atom, char **out)
+get_atom_name_reply(xcb_connection_t *conn, xcb_atom_t atom,
+ xcb_get_atom_name_cookie_t cookie, char **out)
{
- xcb_get_atom_name_cookie_t cookie;
xcb_get_atom_name_reply_t *reply;
int length;
char *name;
if (atom == 0) {
*out = NULL;
+ assert(cookie.sequence == 0);
return true;
}
- cookie = xcb_get_atom_name(conn, atom);
reply = xcb_get_atom_name_reply(conn, cookie, NULL);
if (!reply)
return false;