[PATCH weston 2/2] compositor-x11: properly initialize XKB extension
Kristian Høgsberg
hoegsberg at gmail.com
Wed Oct 31 08:29:07 PDT 2012
On Wed, Oct 31, 2012 at 12:13:09AM +0200, Ran Benita wrote:
> 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 <ran234 at gmail.com>
> ---
> src/compositor-x11.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index c654aec..77e8600 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -191,6 +191,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,24 @@ 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, &error);
> + if (!use_ext_reply || error) {
> + weston_log("couldn't start using XKB extension (error code %d)\n",
> + error->error_code);
> + 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);
> + return;
> + }
We need to free error and use_ext_reply.
Kristian
> +
> pcf = xcb_xkb_per_client_flags(c->conn,
> XCB_XKB_ID_USE_CORE_KBD,
> XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT,
> --
> 1.8.0
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list