From 6a39d8790ec6d26c17778547ce66e94c1bc73032 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 31 Oct 2012 20:14:57 +0200 Subject: [PATCH] compositor-x11: properly initialize XKB extension In order to use XKB capabilities (as we do), the client must issue an XkbUseExtension request: http://www.x.org/releases/current/doc/kbproto/xkbproto.html#Initializing_the_X_Keyboard_Extension The reason this succeeds currently is that XOpenDisplay from Xlib does this for us. But it is better not to rely on that, but do it explicitly in XCB with the rest of the XKB init sequence. Signed-off-by: Ran Benita --- src/compositor-x11.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/compositor-x11.c b/src/compositor-x11.c index c69b8f67..001dec4d 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -190,6 +190,8 @@ x11_compositor_setup_xkb(struct x11_compositor *c) const xcb_query_extension_reply_t *ext; xcb_generic_error_t *error; xcb_void_cookie_t select; + xcb_xkb_use_extension_cookie_t use_ext; + xcb_xkb_use_extension_reply_t *use_ext_reply; xcb_xkb_per_client_flags_cookie_t pcf; xcb_xkb_per_client_flags_reply_t *pcf_reply; xcb_xkb_get_state_cookie_t state; @@ -220,6 +222,25 @@ x11_compositor_setup_xkb(struct x11_compositor *c) return; } + use_ext = xcb_xkb_use_extension(c->conn, + XCB_XKB_MAJOR_VERSION, + XCB_XKB_MINOR_VERSION); + use_ext_reply = xcb_xkb_use_extension_reply(c->conn, use_ext, NULL); + if (!use_ext_reply) { + weston_log("couldn't start using XKB extension\n"); + return; + } + + if (!use_ext_reply->supported) { + weston_log("XKB extension version on the server is too old " + "(want %d.%d, has %d.%d)\n", + XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION, + use_ext_reply->serverMajor, use_ext_reply->serverMinor); + free(use_ext_reply); + return; + } + free(use_ext_reply); + pcf = xcb_xkb_per_client_flags(c->conn, XCB_XKB_ID_USE_CORE_KBD, XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT,