diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2019-01-24 13:34:51 +0100 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2019-02-13 12:30:56 +0000 |
commit | ab67256fe8d9df5be95919852100f7f914ddbb81 (patch) | |
tree | f9ce6177615a33a8a7b092b1c8bf45b4e2245b9c /src/webenginewidgets | |
parent | c4328812031d1efd3409335e63b0e82f76f00924 (diff) |
Simplify visual properties handling in RenderWidgetHostViewQt
Replace separate notifications from delegate with one combined notification and
change detection. Store view rect, window rect and screen info in RWHVQ to
ensure the properties are in a consistent state.
Change-Id: Icef8a17e72882f56db249f5553b6cf554e1f91dc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp | 24 | ||||
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h | 4 |
2 files changed, 6 insertions, 22 deletions
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 5b464a461..efdfb17d0 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -233,15 +233,9 @@ void RenderWidgetHostViewQtDelegateWidget::closeEvent(QCloseEvent *event) m_client->closePopup(); } -QRectF RenderWidgetHostViewQtDelegateWidget::screenRect() const +QRectF RenderWidgetHostViewQtDelegateWidget::viewGeometry() const { - return QRectF(x(), y(), width(), height()); -} - -QRectF RenderWidgetHostViewQtDelegateWidget::contentsRect() const -{ - QPointF pos = mapToGlobal(QPoint(0, 0)); - return QRectF(pos.x(), pos.y(), width(), height()); + return QRectF(mapToGlobal(pos()), size()); } void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus() @@ -378,14 +372,7 @@ QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQ void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent) { QQuickWidget::resizeEvent(resizeEvent); - - const QPoint globalPos = mapToGlobal(pos()); - if (globalPos != m_lastGlobalPos) { - m_lastGlobalPos = globalPos; - m_client->windowBoundsChanged(); - } - - m_client->notifyResize(); + m_client->visualPropertiesChanged(); } void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event) @@ -401,7 +388,7 @@ void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event) m_windowConnections.append(connect(w, SIGNAL(xChanged(int)), SLOT(onWindowPosChanged()))); m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged()))); } - m_client->windowChanged(); + m_client->visualPropertiesChanged(); m_client->notifyShown(); } @@ -497,8 +484,7 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged() { - m_lastGlobalPos = mapToGlobal(pos()); - m_client->windowBoundsChanged(); + m_client->visualPropertiesChanged(); } } // namespace QtWebEngineCore diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index c1cd90093..a736aa5cf 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -66,8 +66,7 @@ public: ~RenderWidgetHostViewQtDelegateWidget(); void initAsPopup(const QRect&) override; - QRectF screenRect() const override; - QRectF contentsRect() const override; + QRectF viewGeometry() const override; void setKeyboardFocus() override; bool hasKeyboardFocus() override; void lockMouse() override; @@ -111,7 +110,6 @@ private: QScopedPointer<QQuickItem> m_rootItem; bool m_isPopup; QColor m_clearColor; - QPoint m_lastGlobalPos; QList<QMetaObject::Connection> m_windowConnections; QWebEnginePage *m_page = nullptr; QMetaObject::Connection m_parentDestroyedConnection; |