diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 0deb5271c5..0c30de498c 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -42,6 +42,7 @@ #include "qscreen.h" #include "qscreen_p.h" #include "qpixmap.h" +#include "qguiapplication_p.h" #include #include @@ -367,6 +368,7 @@ void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) Q_D(QScreen); d->orientationUpdateMask = mask; d->platformScreen->setOrientationUpdateMask(mask); + QGuiApplicationPrivate::updateFilteredScreenOrientation(this); } /*! diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp index cc08379251..5567f127c9 100644 --- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp +++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp @@ -185,19 +185,34 @@ void tst_QScreen::orientationChange() screen->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation); + QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation); + QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation); QSignalSpy spy(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation))); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation); + QWindowSystemInterface::flushWindowSystemEvents(); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation); + QWindowSystemInterface::flushWindowSystemEvents(); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation); + QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation); QCOMPARE(spy.count(), 1); + + spy.clear(); + QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation); + QWindowSystemInterface::flushWindowSystemEvents(); + QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation); + QCOMPARE(spy.count(), 0); + + screen->setOrientationUpdateMask(screen->orientationUpdateMask() | Qt::InvertedLandscapeOrientation); + QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation); + QCOMPARE(spy.count(), 1); } #include