winrt: Remove yet another Windows Phone leftover
Hardware and camera button handling are phone specific APIs we no longer support in Qt. Change-Id: Ib11f894a426b8e4b71acf24876437ddab2cea548 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
parent
7ba16f4c1e
commit
f9d8762d37
@ -195,11 +195,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
|
||||
incDirs << crtInclude + QStringLiteral("/winrt");
|
||||
|
||||
if (winrtBuild) {
|
||||
// Only use mobile-specific headers and link against store-specific libs for
|
||||
// winrt builds.
|
||||
incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/")
|
||||
+ crtVersion + QStringLiteral("/Include/WinRT");
|
||||
|
||||
libDirs << toolsInstallDir + QStringLiteral("lib/") + arch + QStringLiteral("/store");
|
||||
} else {
|
||||
// Desktop projects may require the atl headers and libs.
|
||||
@ -236,9 +231,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
|
||||
incDirs << crtInclude + QStringLiteral("/shared");
|
||||
incDirs << crtInclude + QStringLiteral("/winrt");
|
||||
|
||||
incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/")
|
||||
+ crtVersion + QStringLiteral("/Include/WinRT");
|
||||
|
||||
libDirs << vcInstallDir + QStringLiteral("lib/store/") + compilerArch;
|
||||
libDirs << vcInstallDir + QStringLiteral("atlmfc/lib") + compilerArch;
|
||||
|
||||
|
@ -75,13 +75,6 @@
|
||||
#include <windows.ui.viewmanagement.h>
|
||||
#include <windows.graphics.display.h>
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
# include <windows.phone.ui.input.h>
|
||||
# include <windows.foundation.metadata.h>
|
||||
using namespace ABI::Windows::Foundation::Metadata;
|
||||
#endif
|
||||
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Microsoft::WRL::Wrappers;
|
||||
using namespace ABI::Windows::Foundation;
|
||||
@ -92,27 +85,14 @@ using namespace ABI::Windows::UI::Core;
|
||||
using namespace ABI::Windows::UI::ViewManagement;
|
||||
using namespace ABI::Windows::Graphics::Display;
|
||||
using namespace ABI::Windows::ApplicationModel::Core;
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
using namespace ABI::Windows::Phone::UI::Input;
|
||||
#endif
|
||||
|
||||
typedef IEventHandler<IInspectable *> ResumeHandler;
|
||||
typedef IEventHandler<SuspendingEventArgs *> SuspendHandler;
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
typedef IEventHandler<BackPressedEventArgs*> BackPressedHandler;
|
||||
typedef IEventHandler<CameraEventArgs*> CameraButtonHandler;
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef HRESULT (__stdcall ICoreApplication::*CoreApplicationCallbackRemover)(EventRegistrationToken);
|
||||
uint qHash(CoreApplicationCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); }
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
typedef HRESULT (__stdcall IHardwareButtonsStatics::*HardwareButtonsCallbackRemover)(EventRegistrationToken);
|
||||
uint qHash(HardwareButtonsCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); }
|
||||
typedef HRESULT (__stdcall IHardwareButtonsStatics2::*HardwareButtons2CallbackRemover)(EventRegistrationToken);
|
||||
uint qHash(HardwareButtons2CallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); }
|
||||
#endif
|
||||
|
||||
class QWinRTIntegrationPrivate
|
||||
{
|
||||
@ -128,15 +108,6 @@ public:
|
||||
|
||||
ComPtr<ICoreApplication> application;
|
||||
QHash<CoreApplicationCallbackRemover, EventRegistrationToken> applicationTokens;
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
ComPtr<IHardwareButtonsStatics> hardwareButtons;
|
||||
QHash<HardwareButtonsCallbackRemover, EventRegistrationToken> buttonsTokens;
|
||||
ComPtr<IHardwareButtonsStatics2> cameraButtons;
|
||||
QHash<HardwareButtons2CallbackRemover, EventRegistrationToken> cameraTokens;
|
||||
boolean hasHardwareButtons;
|
||||
bool cameraHalfPressed : 1;
|
||||
bool cameraPressed : 1;
|
||||
#endif
|
||||
};
|
||||
|
||||
QWinRTIntegration::QWinRTIntegration() : d_ptr(new QWinRTIntegrationPrivate)
|
||||
@ -156,45 +127,6 @@ QWinRTIntegration::QWinRTIntegration() : d_ptr(new QWinRTIntegrationPrivate)
|
||||
&d->applicationTokens[&ICoreApplication::remove_Resuming]);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
d->hasHardwareButtons = false;
|
||||
ComPtr<IApiInformationStatics> apiInformationStatics;
|
||||
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Foundation_Metadata_ApiInformation).Get(),
|
||||
IID_PPV_ARGS(&apiInformationStatics));
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
const HStringReference valueRef(L"Windows.Phone.UI.Input.HardwareButtons");
|
||||
hr = apiInformationStatics->IsTypePresent(valueRef.Get(), &d->hasHardwareButtons);
|
||||
}
|
||||
|
||||
if (d->hasHardwareButtons) {
|
||||
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Phone_UI_Input_HardwareButtons).Get(),
|
||||
IID_PPV_ARGS(&d->hardwareButtons));
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
hr = d->hardwareButtons->add_BackPressed(Callback<BackPressedHandler>(this, &QWinRTIntegration::onBackButtonPressed).Get(),
|
||||
&d->buttonsTokens[&IHardwareButtonsStatics::remove_BackPressed]);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
|
||||
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Phone_UI_Input_HardwareButtons).Get(),
|
||||
IID_PPV_ARGS(&d->cameraButtons));
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
if (qEnvironmentVariableIntValue("QT_QPA_ENABLE_CAMERA_KEYS")) {
|
||||
hr = d->cameraButtons->add_CameraPressed(Callback<CameraButtonHandler>(this, &QWinRTIntegration::onCameraPressed).Get(),
|
||||
&d->cameraTokens[&IHardwareButtonsStatics2::remove_CameraPressed]);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
hr = d->cameraButtons->add_CameraHalfPressed(Callback<CameraButtonHandler>(this, &QWinRTIntegration::onCameraHalfPressed).Get(),
|
||||
&d->cameraTokens[&IHardwareButtonsStatics2::remove_CameraHalfPressed]);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
hr = d->cameraButtons->add_CameraReleased(Callback<CameraButtonHandler>(this, &QWinRTIntegration::onCameraReleased).Get(),
|
||||
&d->cameraTokens[&IHardwareButtonsStatics2::remove_CameraReleased]);
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
}
|
||||
d->cameraPressed = false;
|
||||
d->cameraHalfPressed = false;
|
||||
}
|
||||
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
|
||||
|
||||
QEventDispatcherWinRT::runOnXamlThread([d]() {
|
||||
d->mainScreen = new QWinRTScreen;
|
||||
return S_OK;
|
||||
@ -214,18 +146,6 @@ QWinRTIntegration::~QWinRTIntegration()
|
||||
Q_D(QWinRTIntegration);
|
||||
HRESULT hr;
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
if (d->hasHardwareButtons) {
|
||||
for (QHash<HardwareButtonsCallbackRemover, EventRegistrationToken>::const_iterator i = d->buttonsTokens.begin(); i != d->buttonsTokens.end(); ++i) {
|
||||
hr = (d->hardwareButtons.Get()->*i.key())(i.value());
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
}
|
||||
for (QHash<HardwareButtons2CallbackRemover, EventRegistrationToken>::const_iterator i = d->cameraTokens.begin(); i != d->cameraTokens.end(); ++i) {
|
||||
hr = (d->cameraButtons.Get()->*i.key())(i.value());
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Do not execute this on Windows Phone as the application is already
|
||||
// shutting down and trying to unregister suspending/resume handler will
|
||||
// cause exceptions and assert in debug mode
|
||||
@ -353,58 +273,6 @@ QPlatformTheme *QWinRTIntegration::createPlatformTheme(const QString &name) cons
|
||||
|
||||
// System-level integration points
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
HRESULT QWinRTIntegration::onBackButtonPressed(IInspectable *, IBackPressedEventArgs *args)
|
||||
{
|
||||
Q_D(QWinRTIntegration);
|
||||
QWindow *window = d->mainScreen->topWindow();
|
||||
QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
|
||||
const bool pressed = QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyPress, Qt::Key_Back, Qt::NoModifier,
|
||||
0, 0, 0, QString(), false, 1, false);
|
||||
const bool released = QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier,
|
||||
0, 0, 0, QString(), false, 1, false);
|
||||
QWindowSystemInterface::setSynchronousWindowSystemEvents(false);
|
||||
args->put_Handled(pressed || released);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT QWinRTIntegration::onCameraPressed(IInspectable *, ICameraEventArgs *)
|
||||
{
|
||||
Q_D(QWinRTIntegration);
|
||||
QWindow *window = d->mainScreen->topWindow();
|
||||
QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyPress, Qt::Key_Camera, Qt::NoModifier,
|
||||
0, 0, 0, QString(), false, 1, false);
|
||||
d->cameraPressed = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT QWinRTIntegration::onCameraHalfPressed(IInspectable *, ICameraEventArgs *)
|
||||
{
|
||||
Q_D(QWinRTIntegration);
|
||||
QWindow *window = d->mainScreen->topWindow();
|
||||
QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyPress, Qt::Key_CameraFocus, Qt::NoModifier,
|
||||
0, 0, 0, QString(), false, 1, false);
|
||||
d->cameraHalfPressed = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT QWinRTIntegration::onCameraReleased(IInspectable *, ICameraEventArgs *)
|
||||
{
|
||||
Q_D(QWinRTIntegration);
|
||||
QWindow *window = d->mainScreen->topWindow();
|
||||
if (d->cameraHalfPressed)
|
||||
QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyRelease, Qt::Key_CameraFocus, Qt::NoModifier,
|
||||
0, 0, 0, QString(), false, 1, false);
|
||||
|
||||
if (d->cameraPressed)
|
||||
QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyRelease, Qt::Key_Camera, Qt::NoModifier,
|
||||
0, 0, 0, QString(), false, 1, false);
|
||||
d->cameraHalfPressed = false;
|
||||
d->cameraPressed = false;
|
||||
return S_OK;
|
||||
}
|
||||
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
|
||||
HRESULT QWinRTIntegration::onSuspended(IInspectable *, ISuspendingEventArgs *)
|
||||
{
|
||||
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended);
|
||||
|
@ -50,16 +50,6 @@ namespace ABI {
|
||||
namespace Foundation {
|
||||
struct IAsyncAction;
|
||||
}
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
namespace Phone {
|
||||
namespace UI {
|
||||
namespace Input {
|
||||
struct IBackPressedEventArgs;
|
||||
struct ICameraEventArgs;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
struct IAsyncInfo;
|
||||
@ -111,12 +101,6 @@ public:
|
||||
|
||||
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
|
||||
private:
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
HRESULT onBackButtonPressed(IInspectable *, ABI::Windows::Phone::UI::Input::IBackPressedEventArgs *args);
|
||||
HRESULT onCameraPressed(IInspectable *, ABI::Windows::Phone::UI::Input::ICameraEventArgs *);
|
||||
HRESULT onCameraHalfPressed(IInspectable *, ABI::Windows::Phone::UI::Input::ICameraEventArgs *);
|
||||
HRESULT onCameraReleased(IInspectable *, ABI::Windows::Phone::UI::Input::ICameraEventArgs *);
|
||||
#endif
|
||||
HRESULT onSuspended(IInspectable *, ABI::Windows::ApplicationModel::ISuspendingEventArgs *);
|
||||
HRESULT onResume(IInspectable *, IInspectable *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user