From 9c326376c9a27a02ee6abcb897082f538d0002a7 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 27 Feb 2014 18:05:14 +0100 Subject: Add better support for keymap update handling Use the new X11 support API xkb_x11_* released in libxkbcommon version 0.4.0. From the commit message where this API was introduced: "These are function to create an xkb_keymap directly from XKB requests to the X server. This opens up the possibility for X clients to use xcb + xcb-xkb + xkbcommon as a proper replacement for Xlib + xkbfile for keyboard support. Why not just use the RMLVO that the server puts in the _XKB_RULES_NAMES property? This does not account for custom keymaps, on-the-fly keymap modifications, remote clients, etc., so is not a proper solution in practice. Also, some servers don't even set it. Now, the client just needs to recreate the keymap in response to a change in the server's keymap (as Xlib clients do with XRefreshKeyboardMapping() and friends)." This patch moves XKEYBOARD presence decision from compile time to runtime for a proper remote X client support. Task-number: QTBUG-31527 Task-number: QTBUG-32760 Change-Id: I4d402668cda2126ef180b27022154f96b1874b1d Reviewed-by: Uli Schlachter Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbkeyboard.h | 35 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 19 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 0256602782..2eeaff98ef 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -44,11 +44,15 @@ #include "qxcbobject.h" -#ifdef QT_NO_XKB #include -#endif #include +#ifndef QT_NO_XKB +// note: extern won't be needed from libxkbcommon 0.4.1 and above +extern "C" { +#include +} +#endif #include @@ -65,41 +69,37 @@ public: void handleKeyPressEvent(QXcbWindowEventListener *eventListener, const xcb_key_press_event_t *event); void handleKeyReleaseEvent(QXcbWindowEventListener *eventListener, const xcb_key_release_event_t *event); - void handleMappingNotifyEvent(const void *event); Qt::KeyboardModifiers translateModifiers(int s) const; - void updateKeymap(); QList possibleKeys(const QKeyEvent *e) const; -#ifdef QT_NO_XKB - void updateXKBStateFromCore(quint16 state); + // when XKEYBOARD not present on the X server void updateXKBMods(); quint32 xkbModMask(quint16 state); -#else - int coreDeviceId() { return core_device_id; } + void updateXKBStateFromCore(quint16 state); + // when XKEYBOARD is present on the X server + int coreDeviceId() const { return core_device_id; } +#ifndef QT_NO_XKB void updateXKBState(xcb_xkb_state_notify_event_t *state); #endif protected: void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time); - void resolveMaskConflicts(); + void resolveMaskConflicts(); QString keysymToUnicode(xcb_keysym_t sym) const; - int keysymToQtKey(xcb_keysym_t keysym) const; int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, QString text) const; void readXKBConfig(); void clearXKBConfig(); - -#ifdef QT_NO_XKB + // when XKEYBOARD not present on the X server void updateModifiers(); -#else + // when XKEYBOARD is present on the X server void updateVModMapping(); void updateVModToRModMapping(); -#endif private: bool m_config; @@ -120,9 +120,8 @@ private: _mod_masks rmod_masks; -#ifdef QT_NO_XKB + // when XKEYBOARD not present on the X server xcb_key_symbols_t *m_key_symbols; - struct _xkb_mods { xkb_mod_index_t shift; xkb_mod_index_t lock; @@ -133,12 +132,10 @@ private: xkb_mod_index_t mod4; xkb_mod_index_t mod5; }; - _xkb_mods xkb_mods; -#else + // when XKEYBOARD is present on the X server _mod_masks vmod_masks; int core_device_id; -#endif }; QT_END_NAMESPACE -- cgit v1.2.3 From 9bb634a6176c639bd6b52d58151e9927c30919d0 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 3 Mar 2014 18:00:33 +0100 Subject: Improve keymap error handling - add QT_XKB_CONFIG_ROOT envvar, this can be used to provide an alternative XKB configuration search paths (default XKB configuration root is detected when building Qt library). At runtime these paths might change - when dropping Qt application binary into a system with different setup. Change-Id: Ia21a3e7f0339c95793c1f543d1a95b1591e5d8df Reviewed-by: Uli Schlachter Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbkeyboard.h | 1 + 1 file changed, 1 insertion(+) (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 2eeaff98ef..36ce1ea2f0 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -92,6 +92,7 @@ protected: QString keysymToUnicode(xcb_keysym_t sym) const; int keysymToQtKey(xcb_keysym_t keysym) const; int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, QString text) const; + void printKeymapError(const QString &error) const; void readXKBConfig(); void clearXKBConfig(); -- cgit v1.2.3