diff -up qtbase-opensource-src-5.4.0-beta/configure.old_xkbcommon qtbase-opensource-src-5.4.0-beta/configure --- qtbase-opensource-src-5.4.0-beta/configure.old_xkbcommon 2014-10-30 14:24:59.457026169 -0500 +++ qtbase-opensource-src-5.4.0-beta/configure 2014-10-30 14:24:59.463026107 -0500 @@ -5143,7 +5143,7 @@ if [ "$CFG_KMS" != "no" ]; then fi # Detect libxkbcommon -MIN_REQ_XKBCOMMON="0.4.1" +MIN_REQ_XKBCOMMON="0.3.0" # currently only xcb platform plugin supports building xkbcommon if [ "$CFG_XCB" != "no" ]; then if [ "$CFG_XKBCOMMON" != "no" ] && [ "$CFG_XKBCOMMON" != "qt" ]; then diff -up qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.cpp.old_xkbcommon qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.cpp --- qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.cpp.old_xkbcommon 2014-10-30 14:24:59.459026148 -0500 +++ qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.cpp 2014-10-30 15:34:39.003727750 -0500 @@ -869,7 +869,7 @@ QList QXcbKeyboard::possibleKeys(co } QList result; - int baseQtKey = keysymToQtKey(sym, modifiers, lookupString(kb_state, event->nativeScanCode())); + int baseQtKey = keysymToQtKey(sym, modifiers, keysymToUnicode(sym)); result += (baseQtKey + modifiers); // The base key is _always_ valid, of course xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift"); @@ -916,7 +916,7 @@ QList QXcbKeyboard::possibleKeys(co continue; Qt::KeyboardModifiers mods = modifiers & ~neededMods; - qtKey = keysymToQtKey(sym, mods, lookupString(kb_state, event->nativeScanCode())); + qtKey = keysymToQtKey(sym, mods, keysymToUnicode(sym)); if (qtKey == baseQtKey) continue; @@ -1361,7 +1361,7 @@ void QXcbKeyboard::handleKeyEvent(xcb_wi Qt::KeyboardModifiers modifiers = translateModifiers(state); - QString string = lookupString(xkb_state, code); + QString string = keysymToUnicode(sym); int count = string.size(); string.truncate(count); @@ -1425,12 +1425,18 @@ void QXcbKeyboard::handleKeyEvent(xcb_wi } } -QString QXcbKeyboard::lookupString(struct xkb_state *state, xcb_keycode_t code) const +QString QXcbKeyboard::keysymToUnicode(xcb_keysym_t sym) const { QByteArray chars; - chars.resize(1 + xkb_state_key_get_utf8(state, code, 0, 0)); - // equivalent of XLookupString - xkb_state_key_get_utf8(state, code, chars.data(), chars.size()); + int bytes; + chars.resize(7); + + bytes = xkb_keysym_to_utf8(sym, chars.data(), chars.size()); + + if (bytes == -1) + qWarning("QXcbKeyboard::handleKeyEvent - buffer too small"); + chars.resize(bytes-1); + return QString::fromUtf8(chars); } diff -up qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.h.old_xkbcommon qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.h --- qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.h.old_xkbcommon 2014-10-30 14:24:59.459026148 -0500 +++ qtbase-opensource-src-5.4.0-beta/src/plugins/platforms/xcb/qxcbkeyboard.h 2014-10-30 14:24:59.464026096 -0500 @@ -75,7 +75,7 @@ protected: void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time); void resolveMaskConflicts(); - QString lookupString(struct xkb_state *state, xcb_keycode_t code) const; + 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 char *error) const;