Android: Make foreign windows expect global coordinates.

The foreign window implementation was trying to handle parent/child
relationships, but it's not supported by the platform implementation
and was therefore causing more problems then it was solving. E.g.,
even simple use cases, such as the parent moving or re-sizing its
geometry would not be handle correctly.
With this change the parent/child relationship is removed and the
geometry of the foreign window will always expect the geometry to
be in the global coordinate system.

Task-number: QTBUG-43391
Change-Id: I02a1f9cb9eb9fb5ace9b7e912c523bda7c5bfd5c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
Christian Strømme 2015-04-20 16:50:52 +02:00 committed by Christian Stromme
parent 411a3490fd
commit 3753667b2b

View File

@ -73,19 +73,10 @@ void QAndroidPlatformForeignWindow::raise()
void QAndroidPlatformForeignWindow::setGeometry(const QRect &rect) void QAndroidPlatformForeignWindow::setGeometry(const QRect &rect)
{ {
QWindow *parent = window()->parent(); QAndroidPlatformWindow::setGeometry(rect);
QRect newGeometry = rect;
if (parent != 0)
newGeometry.moveTo(parent->mapToGlobal(rect.topLeft()));
if (newGeometry == geometry())
return;
QAndroidPlatformWindow::setGeometry(newGeometry);
if (m_surfaceId != -1) if (m_surfaceId != -1)
QtAndroid::setSurfaceGeometry(m_surfaceId, newGeometry); QtAndroid::setSurfaceGeometry(m_surfaceId, rect);
} }
void QAndroidPlatformForeignWindow::setVisible(bool visible) void QAndroidPlatformForeignWindow::setVisible(bool visible)
@ -118,18 +109,7 @@ void QAndroidPlatformForeignWindow::applicationStateChanged(Qt::ApplicationState
void QAndroidPlatformForeignWindow::setParent(const QPlatformWindow *window) void QAndroidPlatformForeignWindow::setParent(const QPlatformWindow *window)
{ {
QRect newGeometry = geometry(); Q_UNUSED(window);
if (window != 0)
newGeometry.moveTo(window->mapToGlobal(geometry().topLeft()));
if (newGeometry != geometry())
QAndroidPlatformWindow::setGeometry(newGeometry);
if (m_surfaceId == -1)
return;
QtAndroid::setSurfaceGeometry(m_surfaceId, newGeometry);
} }
QT_END_NAMESPACE QT_END_NAMESPACE