diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-03-24 13:15:54 +0000 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-05-07 13:48:08 +0000 |
commit | 3e12951c0b35041920989d6089ddb6c2f5c2d3d1 (patch) | |
tree | 6e4d691d4382fbc0b311fdbaf46ccec04ecdfe70 /src | |
parent | 5dcaa11cc26fabc4f4f1336681ac19217a9e0e91 (diff) |
Remove QScreen::orientationUpdateMask
It simplifies the API and reduces surprise to have rotation working by default.
On Android, the manifest specifies which orientations the application has
been designed to support; on iOS, it is controlled via the
UISupportedInterfaceOrientations property list key.
In addition, QWindow::contentOrientation() is another way to give
a hint to the window manager, or on iOS to directly control whether
the window's rotation is locked or not.
Task-number: QTBUG-35427
Task-number: QTBUG-38576
Task-number: QTBUG-44569
Task-number: QTBUG-51012
Task-number: QTBUG-83055
Change-Id: Ieed818497f686399db23813269af322bfdd237af
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 22 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.cpp | 23 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 56 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qscreen_p.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 13 |
9 files changed, 11 insertions, 111 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 356f9fb11a..8fe06c87e5 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3073,25 +3073,6 @@ void QGuiApplicationPrivate::processScreenOrientationChange(QWindowSystemInterfa QScreen *s = e->screen.data(); s->d_func()->orientation = e->orientation; - updateFilteredScreenOrientation(s); -} - -void QGuiApplicationPrivate::updateFilteredScreenOrientation(QScreen *s) -{ - Qt::ScreenOrientation o = s->d_func()->orientation; - if (o == Qt::PrimaryOrientation) - o = s->primaryOrientation(); - o = Qt::ScreenOrientation(o & s->orientationUpdateMask()); - if (o == Qt::PrimaryOrientation) - return; - if (o == s->d_func()->filteredOrientation) - return; - s->d_func()->filteredOrientation = o; - reportScreenOrientationChange(s); -} - -void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s) -{ emit s->orientationChanged(s->orientation()); QScreenOrientationChangeEvent event(s, s->orientation()); @@ -3126,9 +3107,6 @@ void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfaceP if (s->primaryOrientation() != primaryOrientation) emit s->primaryOrientationChanged(s->primaryOrientation()); - - if (s->d_func()->orientation == Qt::PrimaryOrientation) - updateFilteredScreenOrientation(s); } s->d_func()->emitGeometryChangeSignals(geometryChanged, availableGeometryChanged); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 8ce8f2b2d6..2511f992c7 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -153,7 +153,6 @@ public: static void processApplicationTermination(QWindowSystemInterfacePrivate::WindowSystemEvent *e); static void updateFilteredScreenOrientation(QScreen *screen); - static void reportScreenOrientationChange(QScreen *screen); static void processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e); static void processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); static void processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e); diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 7c1e2158b1..25d2be4b51 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -282,29 +282,6 @@ Qt::ScreenOrientation QPlatformScreen::orientation() const return Qt::PrimaryOrientation; } -/* - Reimplement this function in subclass to filter out unneeded screen - orientation updates. - - The orientations will anyway be filtered before QScreen::orientationChanged() - is emitted, but the mask can be used by the platform plugin for example to - prevent having to have an accelerometer sensor running all the time, or to - improve the reported values. As an example of the latter, in case of only - Landscape | InvertedLandscape being set in the mask, on a platform that gets - its orientation readings from an accelerometer sensor embedded in a handheld - device, the platform can report transitions between the two even when the - device is held in an orientation that's closer to portrait. - - By default, the orientation update mask is empty, so unless this function - has been called with a non-empty mask the platform does not need to report - any orientation updates through - QWindowSystemInterface::handleScreenOrientationChange(). -*/ -void QPlatformScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) -{ - Q_UNUSED(mask); -} - QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window) { // QTBUG 32681: It can happen during the transition between screens diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index 0be7646032..acad5c246b 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -125,7 +125,6 @@ public: virtual Qt::ScreenOrientation nativeOrientation() const; virtual Qt::ScreenOrientation orientation() const; - virtual void setOrientationUpdateMask(Qt::ScreenOrientations mask); virtual QWindow *topLevelAt(const QPoint &point) const; QWindowList windows() const; diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index df628fcc73..3fd1548d04 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -113,11 +113,6 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) refreshRate = 60.0; updatePrimaryOrientation(); - - filteredOrientation = orientation; - if (filteredOrientation == Qt::PrimaryOrientation) - filteredOrientation = primaryOrientation; - updateHighDpi(); } @@ -511,57 +506,24 @@ QRect QScreen::availableVirtualGeometry() const } /*! - Sets the orientations that the application is interested in receiving - updates for in conjunction with this screen. - - For example, to receive orientation() updates and thus have - orientationChanged() signals being emitted for LandscapeOrientation and - InvertedLandscapeOrientation, call setOrientationUpdateMask() with - \a{mask} set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation. - - The default, 0, means no orientationChanged() signals are fired. -*/ -void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) -{ - Q_D(QScreen); - d->orientationUpdateMask = mask; - d->platformScreen->setOrientationUpdateMask(mask); - QGuiApplicationPrivate::updateFilteredScreenOrientation(this); -} - -/*! - Returns the currently set orientation update mask. - - \sa setOrientationUpdateMask() -*/ -Qt::ScreenOrientations QScreen::orientationUpdateMask() const -{ - Q_D(const QScreen); - return d->orientationUpdateMask; -} - -/*! \property QScreen::orientation \brief the screen orientation - The screen orientation represents the physical orientation - of the display. For example, the screen orientation of a mobile device - will change based on how it is being held. A change to the orientation - might or might not trigger a change to the primary orientation of the screen. + The \c orientation property tells the orientation of the screen from the + window system perspective. - Changes to this property will be filtered by orientationUpdateMask(), - so in order to receive orientation updates the application must first - call setOrientationUpdateMask() with a mask of the orientations it wants - to receive. + Most mobile devices and tablet computers contain accelerometer sensors. + The Qt Sensors module provides the ability to read this sensor directly. + However, the windowing system may rotate the entire screen automatically + based on how it is being held; in that case, this \c orientation property + will change. - Qt::PrimaryOrientation is never returned. - - \sa primaryOrientation() + \sa primaryOrientation(), QWindow::contentOrientation(), QOrientationSensor */ Qt::ScreenOrientation QScreen::orientation() const { Q_D(const QScreen); - return d->filteredOrientation; + return d->orientation; } /*! diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 09e1d4259a..039940f196 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -137,9 +137,6 @@ public: Qt::ScreenOrientation orientation() const; Qt::ScreenOrientation nativeOrientation() const; - Qt::ScreenOrientations orientationUpdateMask() const; - void setOrientationUpdateMask(Qt::ScreenOrientations mask); - int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const; QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const; QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const; diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h index 7da542c25e..7543202c2f 100644 --- a/src/gui/kernel/qscreen_p.h +++ b/src/gui/kernel/qscreen_p.h @@ -77,9 +77,7 @@ public: QPlatformScreen *platformScreen = nullptr; - Qt::ScreenOrientations orientationUpdateMask; Qt::ScreenOrientation orientation = Qt::PrimaryOrientation; - Qt::ScreenOrientation filteredOrientation = Qt::PrimaryOrientation; Qt::ScreenOrientation primaryOrientation = Qt::LandscapeOrientation; QRect geometry; QRect availableGeometry; diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h index d5a253461d..4f494815a9 100644 --- a/src/plugins/platforms/ios/qiosscreen.h +++ b/src/plugins/platforms/ios/qiosscreen.h @@ -73,7 +73,6 @@ public: Qt::ScreenOrientation nativeOrientation() const override; Qt::ScreenOrientation orientation() const override; - void setOrientationUpdateMask(Qt::ScreenOrientations mask) override; QPixmap grabWindow(WId window, int x, int y, int width, int height) const override; diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 4dbb0a4cdf..406470ef8e 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -300,6 +300,8 @@ QIOSScreen::QIOSScreen(UIScreen *screen) } } + m_orientationListener = [[QIOSOrientationListener alloc] initWithQIOSScreen:this]; + updateProperties(); m_displayLink = [m_uiScreen displayLinkWithBlock:^(CADisplayLink *) { deliverUpdateRequests(); }]; @@ -520,17 +522,6 @@ Qt::ScreenOrientation QIOSScreen::orientation() const #endif } -void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) -{ - if (m_orientationListener && mask == Qt::PrimaryOrientation) { - [m_orientationListener release]; - m_orientationListener = 0; - } else if (!m_orientationListener) { - m_orientationListener = [[QIOSOrientationListener alloc] initWithQIOSScreen:this]; - updateProperties(); - } -} - QPixmap QIOSScreen::grabWindow(WId window, int x, int y, int width, int height) const { if (window && ![reinterpret_cast<id>(window) isKindOfClass:[UIView class]]) |