summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2019-10-15 13:53:46 +0200
committerChristian Strømme <christian.stromme@qt.io>2020-01-30 14:15:40 +0000
commitcf1fbfea745c510986776965e7f3ffe7c9d65018 (patch)
treecdbf5c9b46f81ba90f78dccf0e8b55f5a69e2aae /src
parentb57176fd63c14b7219d1770e53dda453a8d31af5 (diff)
Fix visibility regression when using offscreen window in qquickwidget
Since s 7ded77d in declarative we keep offscreen window in QQuickWidget as not visible to make input delivery system happy and due to fact that window is really not visible. However, this breaks some behavior in case that "emulated" visibility is required. Switch to track qwindow in case of rendercontrol instead of internal offscreen window. Task-number: QTBUG-79213 Change-Id: If98deb8c56c3ae3c053f4e4d21e6b3b69211a9c3 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/webview/qquickviewcontroller.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/webview/qquickviewcontroller.cpp b/src/webview/qquickviewcontroller.cpp
index 85050d6..11895d6 100644
--- a/src/webview/qquickviewcontroller.cpp
+++ b/src/webview/qquickviewcontroller.cpp
@@ -233,22 +233,36 @@ void QQuickViewController::geometryChanged(const QRectF &newGeometry, const QRec
void QQuickViewController::onWindowChanged(QQuickWindow* window)
{
QQuickWindow *oldParent = qobject_cast<QQuickWindow *>(m_view->parentView());
- if (oldParent != 0)
+ if (oldParent)
oldParent->disconnect(this);
- if (window != 0) {
- connect(window, &QQuickWindow::widthChanged, this, &QQuickViewController::scheduleUpdatePolish);
- connect(window, &QQuickWindow::heightChanged, this, &QQuickViewController::scheduleUpdatePolish);
- connect(window, &QQuickWindow::xChanged, this, &QQuickViewController::scheduleUpdatePolish);
- connect(window, &QQuickWindow::yChanged, this, &QQuickViewController::scheduleUpdatePolish);
- connect(window, &QQuickWindow::sceneGraphInitialized, this, &QQuickViewController::scheduleUpdatePolish);
- connect(window, &QQuickWindow::sceneGraphInvalidated, this, &QQuickViewController::onSceneGraphInvalidated);
- connect(window, &QQuickWindow::visibleChanged, this, [this](bool visible) { m_view->setVisible(visible); });
+ if (!window) {
+ m_view->setParentView(nullptr);
+ return;
}
- // Check if there's an actual window available.
+ // Check if there's an actual native window available.
QWindow *rw = QQuickRenderControl::renderWindowFor(window);
- m_view->setParentView(rw ? rw : window);
+
+ if (rw) {
+ connect(rw, &QWindow::widthChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(rw, &QWindow::heightChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(rw, &QWindow::xChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(rw, &QWindow::yChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(rw, &QWindow::visibleChanged, this, [this](bool visible) { m_view->setVisible(visible); });
+ connect(window, &QQuickWindow::sceneGraphInitialized, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(window, &QQuickWindow::sceneGraphInvalidated, this, &QQuickViewController::onSceneGraphInvalidated);
+ m_view->setParentView(rw);
+ } else {
+ connect(window, &QWindow::widthChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(window, &QWindow::heightChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(window, &QWindow::xChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(window, &QWindow::yChanged, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(window, &QQuickWindow::sceneGraphInitialized, this, &QQuickViewController::scheduleUpdatePolish);
+ connect(window, &QQuickWindow::sceneGraphInvalidated, this, &QQuickViewController::onSceneGraphInvalidated);
+ connect(window, &QWindow::visibleChanged, this, [this](bool visible) { m_view->setVisible(visible); });
+ m_view->setParentView(window);
+ }
}
void QQuickViewController::onVisibleChanged()