winrt: Fix orientation update mask

On WP8.0, setting auto rotation preferences at runtime worked like an
orientation update mask, and did not modify the behavior of the window.
With WP8.1, setting auto rotation preferences has the side effect that the
compositor will then resize the window when moving from e.g. portrait to
landscape. Because of this, the auto rotation API should not be called
inside orientationUpdateMask(). The default implementation is now
sufficient, so the platform override is removed.

Developers looking to set auto rotation preferences should use the
application manifest or call the native api directly.

Task-number: QTBUG-35953
Change-Id: I90cf4290ced34df1bb350cb6aa5deff209622865
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
Andrew Knight 2014-07-15 02:02:58 +03:00
parent a93bfc1ebe
commit c48484ea6d
2 changed files with 5 additions and 14 deletions

View File

@ -432,7 +432,6 @@ class QWinRTScreenPrivate
public:
ComPtr<ICoreApplication> application;
ComPtr<ICoreWindow> coreWindow;
ComPtr<IDisplayInformationStatics> displayInformationStatics;
ComPtr<IDisplayInformation> displayInformation;
#ifdef Q_OS_WINPHONE
ComPtr<IHardwareButtonsStatics> hardwareButtons;
@ -552,11 +551,12 @@ QWinRTScreen::QWinRTScreen()
#endif // Q_OS_WINPHONE
// Orientation handling
ComPtr<IDisplayInformationStatics> displayInformationStatics;
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(),
IID_PPV_ARGS(&d->displayInformationStatics));
IID_PPV_ARGS(&displayInformationStatics));
Q_ASSERT_SUCCEEDED(hr);
hr = d->displayInformationStatics->GetForCurrentView(&d->displayInformation);
hr = displayInformationStatics->GetForCurrentView(&d->displayInformation);
Q_ASSERT_SUCCEEDED(hr);
// Set native orientation
@ -572,9 +572,9 @@ QWinRTScreen::QWinRTScreen()
Q_ASSERT_SUCCEEDED(hr);
// Set initial orientation & pixel density
onOrientationChanged(Q_NULLPTR, Q_NULLPTR);
onDpiChanged(Q_NULLPTR, Q_NULLPTR);
setOrientationUpdateMask(d->nativeOrientation);
d->orientation = d->nativeOrientation;
onOrientationChanged(Q_NULLPTR, Q_NULLPTR);
d->eglDisplay = eglGetDisplay(d->displayInformation.Get());
if (d->eglDisplay == EGL_NO_DISPLAY)
@ -696,14 +696,6 @@ Qt::ScreenOrientation QWinRTScreen::orientation() const
return d->orientation;
}
void QWinRTScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
{
Q_D(QWinRTScreen);
HRESULT hr = d->displayInformationStatics->put_AutoRotationPreferences(nativeOrientationsFromQt(mask));
RETURN_VOID_IF_FAILED("Failed to set display auto rotation preferences.");
}
ICoreWindow *QWinRTScreen::coreWindow() const
{
Q_D(const QWinRTScreen);

View File

@ -107,7 +107,6 @@ public:
Qt::ScreenOrientation nativeOrientation() const;
Qt::ScreenOrientation orientation() const;
void setOrientationUpdateMask(Qt::ScreenOrientations mask);
QWindow *topWindow() const;
void addWindow(QWindow *window);