summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2021-03-07 08:42:54 +0100
committerRan Benita <ran@unusedvar.com>2021-03-09 11:00:13 +0200
commit1b3a1c277a033083fee669e92c8cad862716ebd1 (patch)
tree67e8adea211a9073dae2a2120080356920d5ed02 /src
parentb9707c1db094b601ba23f1fcf5e77ec7b53676b7 (diff)
downloadxorg-lib-libxkbcommon-1b3a1c277a033083fee669e92c8cad862716ebd1.tar.gz
Remove three more round trips
There are a number of XKB requests needed to request all the information from the X11 server. So far, the code was sending one request and waiting for the reply. This commit starts batching the request so that we get multiple replies with one round trip. This removes three round trips. Only the simple requests are converted. get_map() and get_names() use some bitmasks that are needed for both the request and the reply. These will be dealt with separately. Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src')
-rw-r--r--src/x11/keymap.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/x11/keymap.c b/src/x11/keymap.c
index 67319a8..f3f179e 100644
--- a/src/x11/keymap.c
+++ b/src/x11/keymap.c
@@ -749,10 +749,8 @@ get_indicators(struct xkb_keymap *keymap, xcb_connection_t *conn,
static bool
get_indicator_map(struct xkb_keymap *keymap, xcb_connection_t *conn,
- uint16_t device_id)
+ xcb_xkb_get_indicator_map_cookie_t cookie)
{
- xcb_xkb_get_indicator_map_cookie_t cookie =
- xcb_xkb_get_indicator_map(conn, device_id, ALL_INDICATORS_MASK);
xcb_xkb_get_indicator_map_reply_t *reply =
xcb_xkb_get_indicator_map_reply(conn, cookie, NULL);
@@ -831,10 +829,8 @@ fail:
static bool
get_compat_map(struct xkb_keymap *keymap, xcb_connection_t *conn,
- uint16_t device_id)
+ xcb_xkb_get_compat_map_cookie_t cookie)
{
- xcb_xkb_get_compat_map_cookie_t cookie =
- xcb_xkb_get_compat_map(conn, device_id, 0, true, 0, 0);
xcb_xkb_get_compat_map_reply_t *reply =
xcb_xkb_get_compat_map_reply(conn, cookie, NULL);
@@ -1128,10 +1124,8 @@ fail:
static bool
get_controls(struct xkb_keymap *keymap, xcb_connection_t *conn,
- uint16_t device_id)
+ xcb_xkb_get_controls_cookie_t cookie)
{
- xcb_xkb_get_controls_cookie_t cookie =
- xcb_xkb_get_controls(conn, device_id);
xcb_xkb_get_controls_reply_t *reply =
xcb_xkb_get_controls_reply(conn, cookie, NULL);
@@ -1180,17 +1174,23 @@ xkb_x11_keymap_new_from_device(struct xkb_context *ctx,
struct x11_atom_interner interner;
x11_atom_interner_init(&interner, ctx, conn);
- if (!get_map(keymap, conn, device_id) ||
- !get_indicator_map(keymap, conn, device_id) ||
- !get_compat_map(keymap, conn, device_id) ||
- !get_names(keymap, &interner, device_id) ||
- !get_controls(keymap, conn, device_id)) {
- xkb_keymap_unref(keymap);
- return NULL;
- }
+ xcb_xkb_get_indicator_map_cookie_t indicator_map_cookie =
+ xcb_xkb_get_indicator_map(conn, device_id, ALL_INDICATORS_MASK);
+ xcb_xkb_get_compat_map_cookie_t compat_map_cookie =
+ xcb_xkb_get_compat_map(conn, device_id, 0, true, 0, 0);
+ xcb_xkb_get_controls_cookie_t get_controls_cookie =
+ xcb_xkb_get_controls(conn, device_id);
+
+ bool had_error = false;
+ had_error |= !get_map(keymap, conn, device_id);
+ had_error |= !get_indicator_map(keymap, conn, indicator_map_cookie);
+ had_error |= !get_compat_map(keymap, conn, compat_map_cookie);
+ had_error |= !get_names(keymap, &interner, device_id);
+ had_error |= !get_controls(keymap, conn, get_controls_cookie);
x11_atom_interner_round_trip(&interner);
- if (interner.had_error) {
+ had_error |= interner.had_error;
+ if (had_error) {
xkb_keymap_unref(keymap);
return NULL;
}