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>bb10
parent
5dcaa11cc2
commit
3e12951c0b
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -113,11 +113,6 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
|
|||
refreshRate = 60.0;
|
||||
|
||||
updatePrimaryOrientation();
|
||||
|
||||
filteredOrientation = orientation;
|
||||
if (filteredOrientation == Qt::PrimaryOrientation)
|
||||
filteredOrientation = primaryOrientation;
|
||||
|
||||
updateHighDpi();
|
||||
}
|
||||
|
||||
|
|
@ -510,58 +505,25 @@ QRect QScreen::availableVirtualGeometry() const
|
|||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
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;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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]])
|
||||
|
|
|
|||
|
|
@ -982,8 +982,6 @@ public:
|
|||
TestPlugin()
|
||||
{
|
||||
QScreen* screen = QGuiApplication::primaryScreen();
|
||||
// Make sure the orientation we want to send doesn't get filtered out.
|
||||
screen->setOrientationUpdateMask(screen->orientationUpdateMask() | testOrientationToSend);
|
||||
QWindowSystemInterface::handleScreenOrientationChange(screen, testOrientationToSend);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -168,38 +168,33 @@ void tst_QScreen::orientationChange()
|
|||
qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation");
|
||||
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
|
||||
screen->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation);
|
||||
QSignalSpy spy(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)));
|
||||
int expectedSignalCount = 0;
|
||||
|
||||
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
|
||||
QCOMPARE(spy.count(), ++expectedSignalCount);
|
||||
|
||||
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation);
|
||||
|
||||
QSignalSpy spy(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)));
|
||||
QCOMPARE(spy.count(), ++expectedSignalCount);
|
||||
|
||||
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation);
|
||||
QCOMPARE(spy.count(), ++expectedSignalCount);
|
||||
|
||||
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
QTRY_COMPARE(screen->orientation(), Qt::InvertedPortraitOrientation);
|
||||
QCOMPARE(spy.count(), ++expectedSignalCount);
|
||||
|
||||
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);
|
||||
QCOMPARE(spy.count(), ++expectedSignalCount);
|
||||
}
|
||||
|
||||
#include <tst_qscreen.moc>
|
||||
|
|
|
|||
|
|
@ -148,8 +148,7 @@ static void dumpConfiguration(QTextStream &str)
|
|||
<< "\n DevicePixelRatio: " << screen->devicePixelRatio()
|
||||
<< " Primary orientation: " << screen->primaryOrientation()
|
||||
<< "\n Orientation: " << screen->orientation()
|
||||
<< " Native orientation: " << screen->nativeOrientation()
|
||||
<< " OrientationUpdateMask: " << screen->orientationUpdateMask() << '\n';
|
||||
<< " Native orientation: " << screen->nativeOrientation() << '\n';
|
||||
}
|
||||
|
||||
// On Windows, this will provide addition GPU info similar to the output of dxdiag.
|
||||
|
|
|
|||
|
|
@ -225,8 +225,7 @@ void ScreenWatcherMainWindow::startMouseMonitor()
|
|||
|
||||
void screenAdded(QScreen* screen)
|
||||
{
|
||||
screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F);
|
||||
qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), screen->virtualSiblings().count(),
|
||||
qDebug("\nscreenAdded %s siblings %d fast %s", qPrintable(screen->name()), screen->virtualSiblings().count(),
|
||||
(screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name())));
|
||||
ScreenWatcherMainWindow *w = new ScreenWatcherMainWindow(screen);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue