diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-01-07 11:12:35 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-01-07 16:13:51 (GMT) |
commit | 30080bdcb226a5a815465299bcb0dbb6a347cb1c (patch) | |
tree | be702ccfb7197fa90b90f38fa7276cb855da6319 /src/plugins/platforms | |
parent | e24d7c9cab4a50fe682478d43ac74e867666d48b (diff) | |
download | Qt-30080bdcb226a5a815465299bcb0dbb6a347cb1c.zip Qt-30080bdcb226a5a815465299bcb0dbb6a347cb1c.tar.gz Qt-30080bdcb226a5a815465299bcb0dbb6a347cb1c.tar.bz2 |
Lighthouse: Fix keyboard modifier handling
QApplication allready knows the modifiers
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/testlite/qtestlitekeyboard.cpp | 29 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qtestlitekeyboard.h | 1 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/plugins/platforms/testlite/qtestlitekeyboard.cpp b/src/plugins/platforms/testlite/qtestlitekeyboard.cpp index 93d21b3..ca4c203 100644 --- a/src/plugins/platforms/testlite/qtestlitekeyboard.cpp +++ b/src/plugins/platforms/testlite/qtestlitekeyboard.cpp @@ -1,5 +1,7 @@ #include "qtestlitekeyboard.h" +#include <QDebug> + #include "qtestlitescreen.h" #include <QtGui/QWindowSystemInterface> @@ -710,8 +712,8 @@ Qt::KeyboardModifiers QTestLiteKeyboard::translateModifiers(int s) ret |= Qt::AltModifier; if (s & m_meta_mask) ret |= Qt::MetaModifier; - if (s & m_mode_switch_mask) - ret |= Qt::GroupSwitchModifier; +// if (s & m_mode_switch_mask) //doesn't seem to work correctly +// ret |= Qt::GroupSwitchModifier; return ret; } @@ -947,14 +949,21 @@ static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) void QTestLiteKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev) { - int qtcode = 0; - Qt::KeyboardModifiers modifiers = translateModifiers(ev->state); + const int xkeycode = ev->keycode; + const uint xmodifiers = ev->state; + + KeySym baseKeySym; + uint consumedModifiers; + if (!XkbLookupKeySym(m_screen->display(), xkeycode, (xmodifiers & (LockMask | m_num_lock_mask)), + &consumedModifiers, &baseKeySym)) + return; + + Qt::KeyboardModifiers baseModifiers = 0; + int baseCode = -1; QByteArray chars; - chars.resize(513); int count = 0; - KeySym keySym; - count = XLookupString(ev,chars.data(),chars.size(),&keySym,0); - QString text = translateKeySym(keySym,ev->state,qtcode,modifiers,chars,count); - modifiers ^= modifierFromKeyCode(qtcode); - QWindowSystemInterface::handleKeyEvent(widget,ev->time,type,qtcode,modifiers,text.left(count)); + QString text = translateKeySym(baseKeySym, xmodifiers, baseCode, baseModifiers, chars, count); + + QWindowSystemInterface::handleKeyEvent(widget,ev->time,type,baseCode,baseModifiers,text.left(count)); + } diff --git a/src/plugins/platforms/testlite/qtestlitekeyboard.h b/src/plugins/platforms/testlite/qtestlitekeyboard.h index 65ead16..4e9d98d 100644 --- a/src/plugins/platforms/testlite/qtestlitekeyboard.h +++ b/src/plugins/platforms/testlite/qtestlitekeyboard.h @@ -14,6 +14,7 @@ public: Qt::KeyboardModifiers translateModifiers(int s); + enum { MaxBits = sizeof(uint) * 8 }; private: void setMask(KeySym sym, uint mask); |