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/gui/kernel/qwindow.cpp | |
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/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 9d41a72072..8e98958949 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -424,7 +424,7 @@ void QWindowPrivate::setTopLevelScreen(QScreen *newScreen, bool recreate) } } -void QWindowPrivate::create(bool recursive) +void QWindowPrivate::create(bool recursive, WId nativeHandle) { Q_Q(QWindow); if (platformWindow) @@ -433,8 +433,10 @@ void QWindowPrivate::create(bool recursive) if (q->parent()) q->parent()->create(); - platformWindow = QGuiApplicationPrivate::platformIntegration()->createPlatformWindow(q); - Q_ASSERT(platformWindow || q->type() == Qt::ForeignWindow); + QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + platformWindow = nativeHandle ? platformIntegration->createForeignWindow(q, nativeHandle) + : platformIntegration->createPlatformWindow(q); + Q_ASSERT(platformWindow); if (!platformWindow) { qWarning() << "Failed to create platform window for" << q << "with flags" << q->flags(); @@ -629,9 +631,6 @@ WId QWindow::winId() const { Q_D(const QWindow); - if (type() == Qt::ForeignWindow) - return WId(property("_q_foreignWinId").value<WId>()); - if(!d->platformWindow) const_cast<QWindow *>(this)->create(); @@ -865,7 +864,12 @@ void QWindow::setFlags(Qt::WindowFlags flags) Qt::WindowFlags QWindow::flags() const { Q_D(const QWindow); - return d->windowFlags; + Qt::WindowFlags flags = d->windowFlags; + + if (d->platformWindow && d->platformWindow->isForeignWindow()) + flags |= Qt::ForeignWindow; + + return flags; } /*! @@ -2584,13 +2588,13 @@ QWindow *QWindow::fromWinId(WId id) } QWindow *window = new QWindow; - window->setFlags(Qt::ForeignWindow); - window->setProperty("_q_foreignWinId", QVariant::fromValue(id)); - window->create(); + qt_window_private(window)->create(false, id); + if (!window->handle()) { delete window; return nullptr; } + return window; } |