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>
This commit is contained in:
parent
c381df060f
commit
b556890a9f
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user