Android: Don't set geometry when creating surface or adding native view
The window geometry has been propagated to the QtWindow layout already via setGeometry() already, so we don't need the additional plumbing for createSurface and setNativeView. It's enough to set the layout params of the inserted View to match the parent (the QtWindow in this case). Change-Id: I40b44282e80ed04b109ffc1958144cb3e3edd11d Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 9d398a18c24ab0a16ceb0346fc20b8eebf95410d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
292965201a
commit
c9dcb28824
@ -104,7 +104,6 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
|
||||
|
||||
@UsedFromNativeCode
|
||||
void createSurface(final boolean onTop,
|
||||
final int x, final int y, final int w, final int h,
|
||||
final int imageDepth, final boolean isOpaque,
|
||||
final int surfaceContainerType) // TODO constant for type
|
||||
{
|
||||
@ -112,7 +111,6 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
|
||||
if (m_surfaceContainer != null)
|
||||
removeView(m_surfaceContainer);
|
||||
|
||||
setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
|
||||
if (surfaceContainerType == 0) {
|
||||
m_surfaceContainer = new QtSurface(getContext(), QtWindow.this,
|
||||
onTop, imageDepth);
|
||||
@ -165,15 +163,13 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
|
||||
}
|
||||
|
||||
@UsedFromNativeCode
|
||||
void setNativeView(final View view,
|
||||
final int x, final int y, final int w, final int h)
|
||||
void setNativeView(final View view)
|
||||
{
|
||||
QtNative.runAction(()-> {
|
||||
if (m_nativeView != null)
|
||||
removeView(m_nativeView);
|
||||
|
||||
m_nativeView = view;
|
||||
QtWindow.this.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
|
||||
m_nativeView.setLayoutParams(new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
addView(m_nativeView);
|
||||
|
@ -91,11 +91,7 @@ void QAndroidPlatformForeignWindow::addViewToWindow()
|
||||
if (isEmbeddingContainer())
|
||||
return;
|
||||
|
||||
jint x = 0, y = 0, w = -1, h = -1;
|
||||
if (!geometry().isNull())
|
||||
geometry().getRect(&x, &y, &w, &h);
|
||||
|
||||
m_nativeQtWindow.callMethod<void>("setNativeView", m_view, x, y, qMax(w, 1), qMax(h, 1));
|
||||
m_nativeQtWindow.callMethod<void>("setNativeView", m_view);
|
||||
m_nativeViewInserted = true;
|
||||
}
|
||||
|
||||
|
@ -284,19 +284,10 @@ void QAndroidPlatformWindow::applicationStateChanged(Qt::ApplicationState)
|
||||
|
||||
void QAndroidPlatformWindow::createSurface()
|
||||
{
|
||||
const QRect rect = geometry();
|
||||
jint x = 0, y = 0, w = -1, h = -1;
|
||||
if (!rect.isNull()) {
|
||||
x = rect.x();
|
||||
y = rect.y();
|
||||
w = std::max(rect.width(), 1);
|
||||
h = std::max(rect.height(), 1);
|
||||
}
|
||||
|
||||
const bool windowStaysOnTop = bool(window()->flags() & Qt::WindowStaysOnTopHint);
|
||||
const bool isOpaque = !format().hasAlpha() && qFuzzyCompare(window()->opacity(), 1.0);
|
||||
|
||||
m_nativeQtWindow.callMethod<void>("createSurface", windowStaysOnTop, x, y, w, h, 32, isOpaque,
|
||||
m_nativeQtWindow.callMethod<void>("createSurface", windowStaysOnTop, 32, isOpaque,
|
||||
m_surfaceContainerType);
|
||||
m_surfaceCreated = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user