From cca81a663661ef1fce5f4a9f4c5a5f5fd1381325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tinja=20Paavosepp=C3=A4?= Date: Tue, 17 Oct 2023 11:47:49 +0300 Subject: Android: Use TextureView when multiple windows present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/plugins/platforms/android/qandroidplatformwindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/android/qandroidplatformwindow.cpp') 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("createSurface", windowStaysOnTop, x, y, w, h, 32); + m_nativeQtWindow.callMethod("createSurface", windowStaysOnTop, x, y, w, h, 32, isOpaque, + m_surfaceContainerType); m_surfaceCreated = true; } -- cgit v1.2.3