diff options
author | Oliver Wolff <oliver.wolff@digia.com> | 2013-11-19 12:47:03 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-23 19:58:34 +0100 |
commit | d4c548ce5c0bd8a70c82ed082bc69fd41e9c47ed (patch) | |
tree | 5162709d8246bc8a9d815030de829ddcb766ceb1 /src | |
parent | a0e32cbf74e977cdb02defc91081f19b7746c392 (diff) |
Fixed assert in Windows key handling
Certain key sequences (like press alt, press left, release left,
release alt) can cause an assert in qwindowskeymapper. This
behavior was introduced in change
I4f7709a90906b03f4504deea1ff5c361e9f94b3f (Fix virtual key
mapping on MS Windows). The place that seems to cause the new
behavior is changing the bitmask for obtaining the event's scancode.
With the changed bitmask releasing the alt key in the given
key sequence causes the WM_KEYUP event to trigger a WM_CHAR event
which should not happen there. To be honest I don't know how having
the extended bit inside the scancode fixes the behavior but it seems
to do and I could not find another place which might cause the
breakage.
Task-number: QTBUG-35005
Change-Id: Ia18c2681ea311196441a5cd15017e220ac095674
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/windows/qwindowskeymapper.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index e2594207fe..2743ef029d 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -86,6 +86,10 @@ QWindowsKeyMapper::~QWindowsKeyMapper() #define VK_OEM_3 0xC0 #endif +// We not only need the scancode itself but also the extended bit of key messages. Thus we need +// the additional bit when masking the scancode. +enum { scancodeBitmask = 0x1ff }; + // Key recorder ------------------------------------------------------------------------[ start ] -- struct KeyRecord { KeyRecord(int c, int a, int s, const QString &t) : code(c), ascii(a), state(s), text(t) {} @@ -567,7 +571,7 @@ void QWindowsKeyMapper::updateKeyMap(const MSG &msg) { unsigned char kbdBuffer[256]; // Will hold the complete keyboard state GetKeyboardState(kbdBuffer); - const quint32 scancode = (msg.lParam >> 16) & 0xff; + const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; updatePossibleKeyCodes(kbdBuffer, scancode, msg.wParam); } @@ -754,7 +758,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms { const int msgType = msg.message; - const quint32 scancode = (msg.lParam >> 16) & 0xff; + const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; const quint32 vk_key = msg.wParam; quint32 nModifiers = 0; |