summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbkeyboard.h
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2018-01-04 18:50:59 +0100
committerGatis Paeglis <gatis.paeglis@qt.io>2018-02-24 12:15:08 +0000
commitd5abf545971da717014d316127045fc19edbcd65 (patch)
tree6bb3f2d97c9665f9e11e338940feae53d6f460ba /src/plugins/platforms/xcb/qxcbkeyboard.h
parent9280a04afebef9ee992e75c469e29c0c443b66c6 (diff)
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 <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbkeyboard.h')
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h21
1 files changed, 12 insertions, 9 deletions
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<struct xkb_state, XKBStateDeleter>;
+ using ScopedXKBKeymap = std::unique_ptr<struct xkb_keymap, XKBKeymapDeleter>;
+ using ScopedXKBContext = std::unique_ptr<struct xkb_context, XKBContextDeleter>;
+
+ ScopedXKBState m_xkbState;
+ ScopedXKBKeymap m_xkbKeymap;
+ ScopedXKBContext m_xkbContext;
};
QT_END_NAMESPACE