summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2019-04-17 17:19:03 +0200
committerAndre de la Rocha <andre.rocha@qt.io>2019-04-18 11:58:26 +0000
commitb556890a9f7dd45550f0d4e9da981e2f779a943b (patch)
tree11980633d42237bdc45056414e3cb47d7827291c
parentc381df060f16a522e6edd3541b09af06c0aa3024 (diff)
Windows QPA: fix media keys losing autorepeat/keycode information
For WM_APPCOMMAND messages that also trigger WM_KEYDOWN/WM_KEYUP, let the latter messages be handled, instead of stripping them and synthesizing a press/release from the command code, in order to get the correct scan codes and autorepeat info. Fixes: QTBUG-73879 Change-Id: I936cd76be87a76dc6b6223eeb246e4e7aee3a4ac Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index c050369801..c5af4d8042 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -879,21 +879,16 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
#if defined(WM_APPCOMMAND)
const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam);
// QTBUG-57198, do not send mouse-synthesized commands as key events in addition
+ bool skipPressRelease = false;
switch (GET_DEVICE_LPARAM(msg.lParam)) {
case FAPPCOMMAND_MOUSE:
return false;
case FAPPCOMMAND_KEY:
- // QTBUG-62838, swallow WM_KEYDOWN, WM_KEYUP for commands that are
- // reflected in VK(s) like VK_MEDIA_NEXT_TRACK. Don't do that for
- // APPCOMMAND_BROWSER_HOME as that one does not trigger two events
- if (cmd != APPCOMMAND_BROWSER_HOME) {
- MSG peekedMsg;
- if (PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_NOREMOVE)
- && peekedMsg.message == WM_KEYDOWN) {
- PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_REMOVE);
- PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_REMOVE);
- }
- }
+ // QTBUG-62838, use WM_KEYDOWN/WM_KEYUP for commands that are reflected
+ // in VK(s) like VK_MEDIA_NEXT_TRACK, to get correct codes and autorepeat.
+ // Don't do that for APPCOMMAND_BROWSER_HOME as that one does not trigger two events.
+ if (cmd != APPCOMMAND_BROWSER_HOME)
+ skipPressRelease = true;
break;
}
@@ -908,7 +903,8 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
return false;
const int qtKey = int(CmdTbl[cmd]);
- sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
+ if (!skipPressRelease)
+ sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
// QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise,
// the keys are not passed to the active media player.
# if QT_CONFIG(shortcut)