From 9581f23ed86c6c208196489b15c04f5f71c1b2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 17 Aug 2016 17:04:39 +0200 Subject: [PATCH] Translate Qt key events through the unicode text with xkbcommon Summary: KKeyServer does an incorrect translation to keysyms: it always translates to the uppercase variant. This change makes the default go through xkbcommon and tries to get the keysym from matching the unicode representation. E.g. an "a" is then recognized as the lower case a, and an "A" as the uppercase one. Only if the translation through text fails we pass back to KKeyServer which does a reasonable translation for non-text symbols. Reviewers: #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2471 --- virtualkeyboard.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/virtualkeyboard.cpp b/virtualkeyboard.cpp index 955c3cef36..36410700ed 100644 --- a/virtualkeyboard.cpp +++ b/virtualkeyboard.cpp @@ -42,6 +42,8 @@ along with this program. If not, see . #include #include #include +// xkbcommon +#include using namespace KWayland::Server; @@ -411,8 +413,11 @@ bool VirtualKeyboard::eventFilter(QObject *o, QEvent *e) if (event->nativeScanCode() == 0) { // this is a key composed by the virtual keyboard - we need to send it to the client // TODO: proper xkb support in KWindowSystem needed - int sym = 0; - KKeyServer::keyQtToSymX(event->key(), &sym); + int sym = xkb_keysym_from_name(event->text().toUtf8().constData(), XKB_KEYSYM_NO_FLAGS); + if (sym == XKB_KEY_NoSymbol) { + // mapping from text failed, try mapping through KKeyServer + KKeyServer::keyQtToSymX(event->key(), &sym); + } if (sym != 0) { if (waylandServer()) { auto t = waylandServer()->seat()->focusedTextInput();