diff options
author | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2023-10-17 11:47:49 +0300 |
---|---|---|
committer | Soheil Armin <soheil.armin@qt.io> | 2023-12-14 00:26:55 +0200 |
commit | cca81a663661ef1fce5f4a9f4c5a5f5fd1381325 (patch) | |
tree | 8ed1f948368a96a7084e12670052f65efaf63e77 /src/plugins/platforms/android/qandroidplatformwindow.cpp | |
parent | b2e44a2d1d1fa109bb2971177a4fda1210637410 (diff) |
Android: Use TextureView when multiple windows present
The SurfaceView class is not the best option for when we
have multiple windows, as the created Surface can only
either be below the window or on top of it, it is not a
part of the view hierarchy.
Replace the SurfaceView with TextureView when there are
more than one window. This way the surface will be a part
of the view hierarchy, and will respect z-ordering.
When there is only one window, keep using the SurfaceView
approach to limit the effect on existing apps, as well
as enable some of the benefits SurfaceView has for e.g.
game and multimedia apps, such as HDR ability.
Move touch handling from QtSurface to QtWindow, so
touches are handled also when using TextureView instead
of QtSurface aka SurfaceView.
Pick-to: 6.7
Task-number: QTBUG-118142
Change-Id: I37dcaf0fb656cfc1ff2eca0a3bfe7259f607411c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformwindow.cpp')
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformwindow.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index 6681f1d20d..0756fb115f 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -55,6 +55,14 @@ QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window) if (window->isTopLevel()) platformScreen()->addWindow(this); + + // TODO should handle case where this changes at runtime -> need to change existing window + // into TextureView (or perhaps not, if the parent window would be SurfaceView, as long as + // onTop was false it would stay below the children) + if (platformScreen()->windows().size() > 1) + m_surfaceContainerType = SurfaceContainer::TextureView; + else + m_surfaceContainerType = SurfaceContainer::SurfaceView; } QAndroidPlatformWindow::~QAndroidPlatformWindow() @@ -236,8 +244,10 @@ void QAndroidPlatformWindow::createSurface() } const bool windowStaysOnTop = bool(window()->flags() & Qt::WindowStaysOnTopHint); + const bool isOpaque = format().hasAlpha() || (0.0 < window()->opacity() < 1.0); - m_nativeQtWindow.callMethod<void>("createSurface", windowStaysOnTop, x, y, w, h, 32); + m_nativeQtWindow.callMethod<void>("createSurface", windowStaysOnTop, x, y, w, h, 32, isOpaque, + m_surfaceContainerType); m_surfaceCreated = true; } |