Commit 9581f23e authored by Martin Flöser's avatar Martin Flöser
Browse files

Translate Qt key events through the unicode text with xkbcommon

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:
parent ea22b8f1
......@@ -42,6 +42,8 @@ along with this program. If not, see <>.
#include <QQuickItem>
#include <QQuickView>
#include <QQuickWindow>
// xkbcommon
#include <xkbcommon/xkbcommon.h>
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();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment