diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-01-16 09:06:06 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-03-30 13:03:49 +0100 |
commit | a35a7fcb5a713956e97bc87ccbd273737c7418df (patch) | |
tree | 14aca562752c4b2444243b589fe6b5c53913a24c /src/plugins/platforms/android/qandroidplatformintegration.cpp | |
parent | 3f73995a03c4b40e2648cb9af5d3e7ca393bf597 (diff) |
Android: Implement MaximizeUsingFullscreenGeometryHint
(This reintroduces c17a5cec1901dd23f4c39ec2ae47a060fbb06895,
which was reverted in Qt 5 because it requires API level 23.)
This flag tells the app to use as much of the screen as possible
while still keeping system UI visible, and can be supported on Android
by using translucent system UI, similar to iOS.
What this does:
1. It changes the current fullscreen/not-fullscreen logic to
allow three states: fullscreen, fullscreen with translucent
decorations and not-fullscreen.
2. In order for it to work, we have to send the actual
screen geometry and available geometry, at least in the case
where the user needs to know the available geometry to
know the safe area of the window. So we get the real screen
metrics and pass these to the QPA plugin (API level 17, so
we can do that now that the minimum version is 21.)
3. Note that getting the insets and calculating the useable
area does not work for non-fullscreen windows, since Android
is quite inconsistent in this respect. So in this case we
just use the window size and origin of 0,0 for the available
geometry.
4. Since we are touching this code anyway, this patch also tries to use
more consistent wording (calling it "available geometry" everywhere
instead of desktop geometry in some places and just geometry in
others, etc.)
[ChangeLog][Android] Qt::MaximizeUsingFullscreenGeometryHint window
flag is now supported, and will make the window fullscreen, but keep
the system UI on-screen, with a translucent background color.
Fixes: QTBUG-74202
Change-Id: I4cc5ef9cc2a3bd22d4d8d2bb767c6ff8a3aa75c0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformintegration.cpp')
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformintegration.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 7f9fe1f05b..837b1974a6 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -82,12 +82,9 @@ QT_BEGIN_NAMESPACE -int QAndroidPlatformIntegration::m_defaultGeometryWidth = 320; -int QAndroidPlatformIntegration::m_defaultGeometryHeight = 455; -int QAndroidPlatformIntegration::m_defaultScreenWidth = 320; -int QAndroidPlatformIntegration::m_defaultScreenHeight = 455; -int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth = 50; -int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; +QSize QAndroidPlatformIntegration::m_defaultScreenSize = QSize(320, 455); +QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry = QRect(0, 0, 320, 455); +QSize QAndroidPlatformIntegration::m_defaultPhysicalSize = QSize(50, 71); Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; @@ -180,9 +177,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen = new QAndroidPlatformScreen(); QWindowSystemInterface::handleScreenAdded(m_primaryScreen); - m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); - m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); + m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); + m_primaryScreen->setSize(m_defaultScreenSize); + m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); m_mainThread = QThread::currentThread(); @@ -281,6 +278,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity(); case RasterGLSurface: return QtAndroid::activity(); case TopStackedNativeChildWindows: return false; + case MaximizeUsingFullscreenGeometry: return true; default: return QPlatformIntegration::hasCapability(cap); } @@ -435,20 +433,19 @@ QPlatformTheme *QAndroidPlatformIntegration::createPlatformTheme(const QString & return 0; } -void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int screenWidth, int screenHeight) +void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int availableLeft, + int availableTop, + int availableWidth, + int availableHeight, + int physicalWidth, + int physicalHeight, + int screenWidth, + int screenHeight) { - m_defaultGeometryWidth = gw; - m_defaultGeometryHeight = gh; - m_defaultPhysicalSizeWidth = sw; - m_defaultPhysicalSizeHeight = sh; - m_defaultScreenWidth = screenWidth; - m_defaultScreenHeight = screenHeight; -} - -void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh) -{ - m_defaultGeometryWidth = gw; - m_defaultGeometryHeight = gh; + m_defaultAvailableGeometry = QRect(availableLeft, availableTop, + availableWidth, availableHeight); + m_defaultPhysicalSize = QSize(physicalWidth, physicalHeight); + m_defaultScreenSize = QSize(screenWidth, screenHeight); } void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation, @@ -460,10 +457,9 @@ void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation cur void QAndroidPlatformIntegration::flushPendingUpdates() { - m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, - m_defaultPhysicalSizeHeight)); - m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); + m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); + m_primaryScreen->setSize(m_defaultScreenSize); + m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); } #ifndef QT_NO_ACCESSIBILITY @@ -473,13 +469,13 @@ QPlatformAccessibility *QAndroidPlatformIntegration::accessibility() const } #endif -void QAndroidPlatformIntegration::setDesktopSize(int width, int height) +void QAndroidPlatformIntegration::setAvailableGeometry(const QRect &availableGeometry) { if (m_primaryScreen) - QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height))); + QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, availableGeometry)); } -void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height) +void QAndroidPlatformIntegration::setPhysicalSize(int width, int height) { if (m_primaryScreen) QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height))); |