Android: Create QtWindow before applying QWindow geometry during init
During QAndroidPlatformWindow::initialize() we call setGeometry, which may end up in QAndroidPlatformWindow::setNativeGeometry() via one of the QAndroidPlatformWindow subclasses, i.e. GL, Vulkan, or foreign window. We currently bail out from setNativeGeometry if !m_surfaceCreated, but this is only a workaround for the m_nativeQtWindow not being alive yet. As long as we have a m_nativeQtWindow, we should be able to set the layout parameters of that QtWindow, independently of whether it has a QtSurface or is hosting a foreign Android view. As a start, move the QtWindow initialization earlier in initialize(). The isEmbeddingContainer() check can go at the top, as we shouldn't do any modifications to a window that's purely used to act as a container when embedding Qt in native Android apps. Change-Id: Ia3f0b33e6729f5399946d86799f39877d058511b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io> (cherry picked from commit e2ce1f724f56db8072033665d066ad34f4d4c702) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b9022081b0
commit
913552ad0b
@ -30,8 +30,27 @@ QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window)
|
||||
|
||||
void QAndroidPlatformWindow::initialize()
|
||||
{
|
||||
if (isEmbeddingContainer())
|
||||
return;
|
||||
|
||||
QWindow *window = QPlatformWindow::window();
|
||||
|
||||
if (parent()) {
|
||||
QAndroidPlatformWindow *androidParent = static_cast<QAndroidPlatformWindow*>(parent());
|
||||
if (!androidParent->isEmbeddingContainer())
|
||||
m_nativeParentQtWindow = androidParent->nativeWindow();
|
||||
}
|
||||
|
||||
AndroidBackendRegister *reg = QtAndroid::backendRegister();
|
||||
QtJniTypes::QtInputConnectionListener listener =
|
||||
reg->callInterface<QtJniTypes::QtInputInterface, QtJniTypes::QtInputConnectionListener>(
|
||||
"getInputConnectionListener");
|
||||
|
||||
m_nativeQtWindow = QJniObject::construct<QtJniTypes::QtWindow>(
|
||||
QNativeInterface::QAndroidApplication::context(),
|
||||
isForeignWindow(), m_nativeParentQtWindow, listener);
|
||||
m_nativeViewId = m_nativeQtWindow.callMethod<jint>("getId");
|
||||
|
||||
m_windowFlags = Qt::Widget;
|
||||
m_windowState = Qt::WindowNoState;
|
||||
// the surfaceType is overwritten in QAndroidPlatformOpenGLWindow ctor so let's save
|
||||
@ -57,25 +76,6 @@ void QAndroidPlatformWindow::initialize()
|
||||
setGeometry(finalNativeGeometry);
|
||||
}
|
||||
|
||||
if (isEmbeddingContainer())
|
||||
return;
|
||||
|
||||
if (parent()) {
|
||||
QAndroidPlatformWindow *androidParent = static_cast<QAndroidPlatformWindow*>(parent());
|
||||
if (!androidParent->isEmbeddingContainer())
|
||||
m_nativeParentQtWindow = androidParent->nativeWindow();
|
||||
}
|
||||
|
||||
AndroidBackendRegister *reg = QtAndroid::backendRegister();
|
||||
QtJniTypes::QtInputConnectionListener listener =
|
||||
reg->callInterface<QtJniTypes::QtInputInterface, QtJniTypes::QtInputConnectionListener>(
|
||||
"getInputConnectionListener");
|
||||
|
||||
m_nativeQtWindow = QJniObject::construct<QtJniTypes::QtWindow>(
|
||||
QNativeInterface::QAndroidApplication::context(),
|
||||
isForeignWindow(), m_nativeParentQtWindow, listener);
|
||||
m_nativeViewId = m_nativeQtWindow.callMethod<jint>("getId");
|
||||
|
||||
if (window->isTopLevel())
|
||||
platformScreen()->addWindow(this);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user