diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-01-30 14:57:29 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-02-22 07:58:07 +0000 |
commit | c585802e946d97e7d177ea334a162dc7bc286b84 (patch) | |
tree | 27fd7832b2c5956845b4593686be3d616aa20b2e /src/plugins/platforms/android | |
parent | 5426e689f9d7d5e5e6e1a877578f17c96d248fdd (diff) |
QWindow: Remove "_q_foreignWinId" dynamic property
The platform plugins reading this out of the QWindow was a layering
violation, and propagates the notion that a window can shape shift
into representing a new native handle, while none of the platform
plugins support this.
A foreign QWindow is created via the factory function fromWinId(),
at which point we can pass the WId all the way to the platform
plugin as function arguments, where the platform will create a
corresponding platform-window.
The platform window can then answer the question of whether or
not it's representing a foreign window, which determines a few
behavioral changes here and there, as well as supplying the
native window handle back for QWindow::winId();
[ChangeLog][QtGui][QWindow] The "_q_foreignWinId" dynamic property
is no longer set nor read.
[ChangeLog][QtGui][QPA] The function createForeignWindow() has been
added to QPlatormIntegration and is now responsible for creating
foreign windows. The function isForeignWindow() in QPlatformWindow
has been added, and platforms should implement this to return true
for windows created by createForeignWindow().
Task-number: QTBUG-58383
Change-Id: If84142f95172f62b9377eb5d2a4d792cad36010b
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/plugins/platforms/android')
4 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformforeignwindow.cpp b/src/plugins/platforms/android/qandroidplatformforeignwindow.cpp index 8c1f0ea8d2..1c920c0af9 100644 --- a/src/plugins/platforms/android/qandroidplatformforeignwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformforeignwindow.cpp @@ -45,12 +45,11 @@ QT_BEGIN_NAMESPACE -QAndroidPlatformForeignWindow::QAndroidPlatformForeignWindow(QWindow *window) +QAndroidPlatformForeignWindow::QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle) : QAndroidPlatformWindow(window), m_surfaceId(-1) { - const WId wId = window->property("_q_foreignWinId").value<WId>(); - m_view = reinterpret_cast<jobject>(wId); + m_view = reinterpret_cast<jobject>(nativeHandle); if (m_view.isValid()) QtAndroid::setViewVisibility(m_view.object(), false); } diff --git a/src/plugins/platforms/android/qandroidplatformforeignwindow.h b/src/plugins/platforms/android/qandroidplatformforeignwindow.h index d42c36dcee..af1eee5499 100644 --- a/src/plugins/platforms/android/qandroidplatformforeignwindow.h +++ b/src/plugins/platforms/android/qandroidplatformforeignwindow.h @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE class QAndroidPlatformForeignWindow : public QAndroidPlatformWindow { public: - explicit QAndroidPlatformForeignWindow(QWindow *window); + explicit QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle); ~QAndroidPlatformForeignWindow(); void lower() override; void raise() override; @@ -57,6 +57,7 @@ public: void setVisible(bool visible) override; void applicationStateChanged(Qt::ApplicationState state) override; void setParent(const QPlatformWindow *window) override; + bool isForeignWindow() const override { return true; } private: int m_surfaceId; diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 173431208f..73aa9d0e8a 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -284,10 +284,13 @@ QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWindow *wind { if (!QtAndroid::activity()) return nullptr; - if (window->type() == Qt::ForeignWindow) - return new QAndroidPlatformForeignWindow(window); - else - return new QAndroidPlatformOpenGLWindow(window, m_eglDisplay); + + return new QAndroidPlatformOpenGLWindow(window, m_eglDisplay); +} + +QPlatformWindow *QAndroidPlatformIntegration::createForeignWindow(QWindow *window, WId nativeHandle) const +{ + return new QAndroidPlatformForeignWindow(window, nativeHandle); } QAbstractEventDispatcher *QAndroidPlatformIntegration::createEventDispatcher() const diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index 2337801250..be10c3d161 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -78,6 +78,7 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const override; QPlatformWindow *createPlatformWindow(QWindow *window) const override; + QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; QAbstractEventDispatcher *createEventDispatcher() const override; |