From ce1f994e9bcdea963a81a4bf562a8317cf6e0089 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 26 Sep 2012 15:14:48 +0200 Subject: Fix QScreen::orientation() not always being updated after changing the update orientation mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The back-end might report screen orientation changes at any point and we record it in screen.d->orientation. However QScreen::orientation() returns the orientation filtered according to the mask. Changing the mask sends a notification to the back-end, which might send another update as a result of a possible subscription to system services (accelerometer). However on platforms where no subscription is required, where the platform plugin ignores the mask and always sends the latest orientation, we should "simulate" the update by updating the filtered orientation according to the new mask. The function is cheap to call as it won't emit any signals unless the orientation actually changes. This patch also adds missing flush() calls after handleScreenOrientationChange calls in the tests to ensure that the (synthetic) window system events are actually delivered to QScreen/QGuiApplication. Change-Id: Iebdd050f947e658ff5bc388629aa4cb31ab497fe Reviewed-by: Samuel Rødal Reviewed-by: Laszlo Papp --- tests/auto/gui/kernel/qscreen/tst_qscreen.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/auto/gui/kernel/qscreen/tst_qscreen.cpp') 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 -- cgit v1.2.3