From 594c01dc361d17d88dacae61efaef28c1705e8ef Mon Sep 17 00:00:00 2001 From: Peter Junos Date: Wed, 27 May 2015 02:09:34 +0200 Subject: [PATCH] Xkb setup by calling xkbcommon function --- xkb.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/xkb.c b/xkb.c index 3fa57251..3e1d6245 100644 --- a/xkb.c +++ b/xkb.c @@ -25,7 +25,6 @@ #include #include - /* \brief switch keyboard layout * \param L The Lua VM state. * \return The number of elements pushed on stack. @@ -243,20 +242,18 @@ void xkb_init(void) { - /* check that XKB extension present in this X server */ - const xcb_query_extension_reply_t *xkb_r; - xkb_r = xcb_get_extension_data(globalconf.connection, &xcb_xkb_id); - if (!xkb_r || !xkb_r->present) - { - fatal("Xkb extension not present"); - } + int success_xkb = xkb_x11_setup_xkb_extension(globalconf.connection, + XKB_X11_MIN_MAJOR_XKB_VERSION, + XKB_X11_MIN_MINOR_XKB_VERSION, + 0, + NULL, + NULL, + NULL, + NULL); - /* check xkb version */ - xcb_xkb_use_extension_cookie_t ext_cookie = xcb_xkb_use_extension(globalconf.connection, 1, 0); - xcb_xkb_use_extension_reply_t *ext_reply = xcb_xkb_use_extension_reply (globalconf.connection, ext_cookie, NULL); - if (!ext_reply || !ext_reply->supported) - { - fatal("Required xkb extension is not supported"); + + if (!success_xkb) { + fatal("XKB not found or not supported"); } uint16_t map = XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY;