From d5abf545971da717014d316127045fc19edbcd65 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 4 Jan 2018 18:50:59 +0100 Subject: xcb: re-factor QXcbKeyboard::updateKeymap() to remove various fallbacks 3edcd9420e3ad661cad89420e18dbb70e7ad450b added more robust support for keyboard input on XKeyboard-less X servers. The various fallbacks that we had did not work that well in practice. We can remove them now. The xkb_keymap_new_from_names() function relies on reading XKB config files from a file system. Since we don't use this function anymore, we can also simplify xkb context creation (see XKB_CONTEXT_NO_DEFAULT_INCLUDES), as we don't care about DFLT_XKB_CONFIG_ROOT (which we previously set via -xkb-config-root for the bundled libxkbcommon). This patch also changes the code to use smart pointers for managing the global xkb context, keymap and state. [ChangeLog][X11] The -xkb-config-root command line switch has been removed as it it no longer needed when configuring with -qt-xkbcommon-x11. Change-Id: I80eecf83adae90af5cd20df434c1fba0358a12fd Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbkeyboard.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/xcb/qxcbkeyboard.h') diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h index 8ea16f099b..2e2e26367d 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -90,10 +90,7 @@ protected: QString lookupString(struct xkb_state *state, xcb_keycode_t code) const; int keysymToQtKey(xcb_keysym_t keysym) const; int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, const QString &text) const; - void printKeymapError(const char *error) const; - void readXKBConfig(); - void clearXKBConfig(); struct xkb_keymap *keymapFromCore(); // when XKEYBOARD not present on the X server @@ -111,14 +108,8 @@ private: void updateXKBStateFromState(struct xkb_state *kb_state, quint16 state); bool m_config = false; - bool m_keymap_is_core = false; xcb_keycode_t m_autorepeat_code = 0; - struct xkb_context *xkb_context = nullptr; - struct xkb_keymap *xkb_keymap = nullptr; - struct xkb_state *xkb_state = nullptr; - struct xkb_rule_names xkb_names; - struct _mod_masks { uint alt; uint altgr; @@ -151,7 +142,19 @@ private: struct XKBStateDeleter { void operator()(struct xkb_state *state) const { return xkb_state_unref(state); } }; + struct XKBKeymapDeleter { + void operator()(struct xkb_keymap *keymap) const { return xkb_keymap_unref(keymap); } + }; + struct XKBContextDeleter { + void operator()(struct xkb_context *context) const { return xkb_context_unref(context); } + }; using ScopedXKBState = std::unique_ptr; + using ScopedXKBKeymap = std::unique_ptr; + using ScopedXKBContext = std::unique_ptr; + + ScopedXKBState m_xkbState; + ScopedXKBKeymap m_xkbKeymap; + ScopedXKBContext m_xkbContext; }; QT_END_NAMESPACE -- cgit v1.2.3