From 45862976b7566d416aff887b74eb60cb039a3dd6 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 7 Apr 2017 11:00:54 +0200 Subject: winrt: Fix build for Windows 10 Creators Update Phone specific UI colors have been removed from the windows headers. Continue to use the enum values does not gain anything as the native calls return errors for those. Actually they did that already with 14393. Change-Id: I4b04d3af319766216ae7c550af704aab488c1d15 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrttheme.cpp | 3 +++ src/plugins/platforms/winrt/winrt.pro | 1 + 2 files changed, 4 insertions(+) (limited to 'src/plugins/platforms/winrt') diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index 6b35bde83e..5696ae7a10 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -146,6 +146,8 @@ static void nativeColorSettings(QPalette &p) if (uiColorSettings(L"Hotlight", UIElementType_Hotlight, &color)) p.setColor(QPalette::BrightText, fromColor(color)); + // Starting with SDK 15063 those have been removed. +#ifndef QT_WINRT_DISABLE_PHONE_COLORS //Phone related if (uiColorSettings(L"PopupBackground", UIElementType_PopupBackground, &color)) { p.setColor(QPalette::ToolTipBase, fromColor(color)); @@ -186,6 +188,7 @@ static void nativeColorSettings(QPalette &p) if (uiColorSettings(L"TextContrastWithHigh", UIElementType_TextContrastWithHigh, &color)) p.setColor(QPalette::BrightText, fromColor(color)); +#endif // QT_WINRT_DISABLE_PHONE_COLORS } QWinRTTheme::QWinRTTheme() diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 35801fdacc..02a848b03f 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -51,6 +51,7 @@ OTHER_FILES += winrt.json WINRT_SDK_VERSION_STRING = $$(UCRTVersion) WINRT_SDK_VERSION = $$member($$list($$split(WINRT_SDK_VERSION_STRING, .)), 2) lessThan(WINRT_SDK_VERSION, 14322): DEFINES += QT_WINRT_LIMITED_DRAGANDDROP +greaterThan(WINRT_SDK_VERSION, 14393): DEFINES += QT_WINRT_DISABLE_PHONE_COLORS contains(DEFINES, QT_NO_DRAGANDDROP) { SOURCES -= qwinrtdrag.cpp -- cgit v1.2.3 From ad0249cc793772a342bf6ced40fb44cd52b2b0e6 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 18 Apr 2017 12:47:21 +0200 Subject: 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 --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/winrt') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index edfcf038d7..3a4c3b871c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -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; } -- cgit v1.2.3 From 32b92b9e21a7a684fa9c23b881cda5b913699574 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 19 Apr 2017 08:29:36 +0200 Subject: winrt: Fix keyboard modifier states CoreWindow::GetAsyncKeyState returns flags and not enums so checking equality does not give the needed result. As seen in qwindowskeymapper.cpp key events that only contain a modifier key should not have the key itself as a modifier when calling handleExtendedKeyEvent. With the current approach the modifier states are the same as on desktop Windows. Task-number: QTBUG-58750 Change-Id: Ie0f3e1d3e8294e1a6b41c9223a7a5153306579f6 Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms/winrt') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 3a4c3b871c..7ac4bdac6c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -685,21 +685,26 @@ Qt::KeyboardModifiers QWinRTScreen::keyboardModifiers() const Qt::KeyboardModifiers mods; CoreVirtualKeyStates mod; - d->coreWindow->GetAsyncKeyState(VirtualKey_Shift, &mod); - if (mod == CoreVirtualKeyStates_Down) + HRESULT hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Shift, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::ShiftModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_Menu, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Menu, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::AltModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_Control, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Control, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::ControlModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_LeftWindows, &mod); - if (mod == CoreVirtualKeyStates_Down) { + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_LeftWindows, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) { mods |= Qt::MetaModifier; } else { - d->coreWindow->GetAsyncKeyState(VirtualKey_RightWindows, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_RightWindows, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::MetaModifier; } return mods; @@ -997,11 +1002,21 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind if (key == Qt::Key_unknown || (key >= Qt::Key_Space && key <= Qt::Key_ydiaeresis)) return S_OK; + Qt::KeyboardModifiers modifiers = keyboardModifiers(); + // If the key actually pressed is a modifier key, then we remove its modifier key from the + // state, since a modifier-key can't have itself as a modifier (see qwindowskeymapper.cpp) + if (key == Qt::Key_Control) + modifiers = modifiers ^ Qt::ControlModifier; + else if (key == Qt::Key_Shift) + modifiers = modifiers ^ Qt::ShiftModifier; + else if (key == Qt::Key_Alt) + modifiers = modifiers ^ Qt::AltModifier; + QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), QEvent::KeyPress, key, - keyboardModifiers(), + modifiers, !status.ScanCode ? -1 : status.ScanCode, virtualKey, 0, -- cgit v1.2.3