winrt: Fix QKeyEvent::isAutoRepeat

CorePhysicalKeyStatus::KeyStatus does not give the information we are
after so we have to keep track of "auto repeat" state of the keys
ourself.

Task-number: QTBUG-59232
Change-Id: I22aa185780e5fa1f7f3c23c2deb2a0dde0c4a582
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
bb10
Oliver Wolff 2017-04-18 12:47:21 +02:00
parent ee3ac3a3bf
commit ad0249cc79
1 changed files with 10 additions and 6 deletions

View File

@ -101,22 +101,26 @@ QT_BEGIN_NAMESPACE
struct KeyInfo {
KeyInfo()
: virtualKey(0)
, isAutoRepeat(false)
{
}
KeyInfo(const QString &text, quint32 virtualKey)
: text(text)
, virtualKey(virtualKey)
, isAutoRepeat(false)
{
}
KeyInfo(quint32 virtualKey)
: virtualKey(virtualKey)
, isAutoRepeat(false)
{
}
QString text;
quint32 virtualKey;
bool isAutoRepeat;
};
static inline Qt::ScreenOrientations qtOrientationsFromNative(DisplayOrientations native)
@ -971,6 +975,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind
if (!shouldAutoRepeat(key))
return S_OK;
d->activeKeys[key].isAutoRepeat = true;
// If the key was pressed before trigger a key release before the next key press
QWindowSystemInterface::handleExtendedKeyEvent(
topWindow(),
@ -981,7 +986,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind
virtualKey,
0,
QString(),
status.WasKeyDown,
d->activeKeys.value(key).isAutoRepeat,
!status.RepeatCount ? 1 : status.RepeatCount,
false);
} else {
@ -1001,7 +1006,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind
virtualKey,
0,
QString(),
status.WasKeyDown,
d->activeKeys.value(key).isAutoRepeat,
!status.RepeatCount ? 1 : status.RepeatCount,
false);
return S_OK;
@ -1051,20 +1056,19 @@ HRESULT QWinRTScreen::onCharacterReceived(ICoreWindow *, ICharacterReceivedEvent
const Qt::KeyboardModifiers modifiers = keyboardModifiers();
const Qt::Key key = qKeyFromCode(keyCode, modifiers);
const QString text = QChar(keyCode);
const quint32 virtualKey = d->activeKeys.value(key).virtualKey;
const KeyInfo info = d->activeKeys.value(key);
QWindowSystemInterface::handleExtendedKeyEvent(
topWindow(),
QEvent::KeyPress,
key,
modifiers,
!status.ScanCode ? -1 : status.ScanCode,
virtualKey,
info.virtualKey,
0,
text,
status.WasKeyDown,
info.isAutoRepeat,
!status.RepeatCount ? 1 : status.RepeatCount,
false);
d->activeKeys.insert(key, KeyInfo(text, virtualKey));
return S_OK;
}