Android: Simplify QAndroidPlatformWindow::setGeometry plumbing

Instead of splitting the geometry setting into setGeometry and
setNativeGeometry we can leave setGeometry to do the right choice
of whether to propagate the geometry to the QtWindow layout or not.

Change-Id: I30291dbf7079df76f4d3a54d6ea3c9c3f1329c90
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit b3e60c5acfaf809f376f66d6ab7f98ca644b0fce)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-07-04 13:51:43 +02:00 committed by Qt Cherry-pick Bot
parent f8ae1a4ab1
commit 10cf8c8fde
6 changed files with 17 additions and 35 deletions

View File

@ -42,17 +42,6 @@ QAndroidPlatformForeignWindow::~QAndroidPlatformForeignWindow()
}
void QAndroidPlatformForeignWindow::setGeometry(const QRect &rect)
{
QAndroidPlatformWindow::setGeometry(rect);
if (isEmbeddingContainer())
return;
if (m_nativeViewInserted)
setNativeGeometry(rect);
}
void QAndroidPlatformForeignWindow::setVisible(bool visible)
{
if (isEmbeddingContainer()) {

View File

@ -18,7 +18,6 @@ public:
explicit QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle);
void initialize() override;
~QAndroidPlatformForeignWindow();
void setGeometry(const QRect &rect) override;
void setVisible(bool visible) override;
void applicationStateChanged(Qt::ApplicationState state) override;
bool isForeignWindow() const override { return true; }

View File

@ -46,9 +46,6 @@ void QAndroidPlatformOpenGLWindow::setGeometry(const QRect &rect)
QAndroidPlatformWindow::setGeometry(rect);
setNativeGeometry(rect);
QRect availableGeometry = screen()->availableGeometry();
if (rect.width() > 0
&& rect.height() > 0

View File

@ -39,8 +39,6 @@ void QAndroidPlatformVulkanWindow::setGeometry(const QRect &rect)
m_oldGeometry = geometry();
QAndroidPlatformWindow::setGeometry(rect);
if (m_surfaceCreated)
setNativeGeometry(rect);
QRect availableGeometry = screen()->availableGeometry();
if (rect.width() > 0

View File

@ -136,6 +136,23 @@ QMargins QAndroidPlatformWindow::safeAreaMargins() const
void QAndroidPlatformWindow::setGeometry(const QRect &rect)
{
QPlatformWindow::setGeometry(rect);
if (!isEmbeddingContainer()) {
Q_ASSERT(m_nativeQtWindow.isValid());
jint x = 0;
jint y = 0;
jint w = -1;
jint h = -1;
if (!rect.isNull()) {
x = rect.x();
y = rect.y();
w = rect.width();
h = rect.height();
}
m_nativeQtWindow.callMethod<void>("setGeometry", x, y, w, h);
}
QWindowSystemInterface::handleGeometryChange(window(), rect);
}
@ -293,23 +310,6 @@ void QAndroidPlatformWindow::destroySurface()
}
}
void QAndroidPlatformWindow::setNativeGeometry(const QRect &geometry)
{
Q_ASSERT(m_nativeQtWindow.isValid());
jint x = 0;
jint y = 0;
jint w = -1;
jint h = -1;
if (!geometry.isNull()) {
x = geometry.x();
y = geometry.y();
w = geometry.width();
h = geometry.height();
}
m_nativeQtWindow.callMethod<void>("setGeometry", x, y, w, h);
}
void QAndroidPlatformWindow::onSurfaceChanged(QtJniTypes::Surface surface)
{
lockSurface();

View File

@ -73,7 +73,6 @@ protected:
void unlockSurface() { m_surfaceMutex.unlock(); }
void createSurface();
void destroySurface();
void setNativeGeometry(const QRect &geometry);
void sendExpose() const;
bool blockedByModal() const;
bool isEmbeddingContainer() const;