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)
|
#if defined(WM_APPCOMMAND)
|
||||||
const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam);
|
const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam);
|
||||||
// QTBUG-57198, do not send mouse-synthesized commands as key events in addition
|
// QTBUG-57198, do not send mouse-synthesized commands as key events in addition
|
||||||
|
bool skipPressRelease = false;
|
||||||
switch (GET_DEVICE_LPARAM(msg.lParam)) {
|
switch (GET_DEVICE_LPARAM(msg.lParam)) {
|
||||||
case FAPPCOMMAND_MOUSE:
|
case FAPPCOMMAND_MOUSE:
|
||||||
return false;
|
return false;
|
||||||
case FAPPCOMMAND_KEY:
|
case FAPPCOMMAND_KEY:
|
||||||
// QTBUG-62838, swallow WM_KEYDOWN, WM_KEYUP for commands that are
|
// QTBUG-62838, use WM_KEYDOWN/WM_KEYUP for commands that are reflected
|
||||||
// reflected in VK(s) like VK_MEDIA_NEXT_TRACK. Don't do that for
|
// in VK(s) like VK_MEDIA_NEXT_TRACK, to get correct codes and autorepeat.
|
||||||
// APPCOMMAND_BROWSER_HOME as that one does not trigger two events
|
// Don't do that for APPCOMMAND_BROWSER_HOME as that one does not trigger two events.
|
||||||
if (cmd != APPCOMMAND_BROWSER_HOME) {
|
if (cmd != APPCOMMAND_BROWSER_HOME)
|
||||||
MSG peekedMsg;
|
skipPressRelease = true;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,6 +903,7 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const int qtKey = int(CmdTbl[cmd]);
|
const int qtKey = int(CmdTbl[cmd]);
|
||||||
|
if (!skipPressRelease)
|
||||||
sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
|
sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
|
||||||
// QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise,
|
// 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.
|
// the keys are not passed to the active media player.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user