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
This commit is contained in:
parent
ea22b8f15d
commit
9581f23ed8
1 changed files with 7 additions and 2 deletions
|
@ -42,6 +42,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#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();
|
||||
|
|
Loading…
Reference in a new issue