From 1f176af9d4e8bee8a53ebd6198d8cf4c8aa38a5c Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 15 Apr 2010 13:29:12 +0200 Subject: [PATCH] fakevim: fix ^ when it is a dead key --- src/plugins/fakevim/fakevimhandler.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 8224f687205..07cb01fda43 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -72,6 +72,7 @@ #include #include +#include #include #include #include @@ -3968,6 +3969,21 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev) return false; } + if (active && ev->type() == QEvent::InputMethod && ob == d->editor()) { + // This handles simple dead keys. The sequence of events is + // KeyRelease-InputMethod-KeyRelease for dead keys instead of + // KeyPress-KeyRelease as for simple keys. As vi acts on key presses, + // we have to act on the InputMethod event. + // FIXME: A first approximation working for e.g. ^ on a German keyboard + QInputMethodEvent *imev = static_cast(ev); + KEY_DEBUG("INPUTMETHOD" << imev->commitString() << imev->preeditString()); + QString commitString = imev->commitString(); + int key = commitString.size() == 1 ? commitString.at(0).unicode() : 0; + QKeyEvent kev(QEvent::KeyPress, key, Qt::KeyboardModifiers(), commitString); + EventResult res = d->handleEvent(&kev); + return res == EventHandled; + } + if (active && ev->type() == QEvent::KeyPress && ob == d->editor()) { QKeyEvent *kev = static_cast(ev); KEY_DEBUG("KEYPRESS" << kev->key());