summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-18 14:11:06 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-20 17:13:51 +0200
commit7717f941a349140497d5e689530a2bf31e8397da (patch)
tree10a59c8fdc08bbaabc4c3b21500b56c259021f1a /src/webenginewidgets
parent7ea45766f6c49de9a81a387013fb1b98ab82766d (diff)
Propagate the page's screen coordinates when the top-level window moved
This fixes a regression after the 37 upgrade where the select popups would have the wrong position. Adjust to the new behavior and also avoid doing a mapToGlobal of the position received in InitAsPopup. RWHV::SetBounds has been giving us screen coordinates since the Chromium 33 update, but popup locations somehow managed to work properly through some side-effect sorcery. This also fixes the value of window.screen[XY] in JavaScript which wasn't updated when the window was moved. Change-Id: I544499bafedccfb7d389b4abc48f1386c398473f Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp5
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp21
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h13
4 files changed, 30 insertions, 10 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 3d4906390..e8f34a1ea 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -227,11 +227,6 @@ QRectF QWebEnginePagePrivate::viewportRect() const
return view ? view->rect() : QRectF();
}
-QPoint QWebEnginePagePrivate::mapToGlobal(const QPoint &posInView) const
-{
- return view ? view->mapToGlobal(posInView) : QPoint();
-}
-
qreal QWebEnginePagePrivate::dpiScale() const
{
return 1.0;
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 12f888064..f2f038e41 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -118,7 +118,6 @@ public:
virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE;
virtual void selectionChanged() Q_DECL_OVERRIDE;
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
- virtual QPoint mapToGlobal(const QPoint &posInView) const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
virtual void loadStarted(const QUrl &provisionalUrl) Q_DECL_OVERRIDE;
virtual void loadCommitted() Q_DECL_OVERRIDE;
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 2fb03f02e..36ea5015f 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -201,6 +201,22 @@ void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent
m_client->notifyResize();
}
+void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event)
+{
+ QOpenGLWidget::showEvent(event);
+ // We don't have a way to catch a top-level window change with QWidget
+ // but a widget will most likely be shown again if it changes, so do
+ // the reconnection at this point.
+ foreach (const QMetaObject::Connection &c, m_windowConnections)
+ disconnect(c);
+ m_windowConnections.clear();
+ if (QWindow *w = window()) {
+ m_windowConnections.append(connect(w, SIGNAL(xChanged(int)), SLOT(onWindowPosChanged())));
+ m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged())));
+ }
+ m_client->windowChanged();
+}
+
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
bool handled = false;
@@ -248,3 +264,8 @@ void RenderWidgetHostViewQtDelegateWidget::paintGL()
m_sgRenderer->renderScene(defaultFramebufferObject());
}
+
+void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged()
+{
+ m_client->windowBoundsChanged();
+}
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 68553b8e8..756ad3c14 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -58,8 +58,8 @@ class QSGRootNode;
class QWindow;
QT_END_NAMESPACE
-class RenderWidgetHostViewQtDelegateWidget : public QOpenGLWidget, public RenderWidgetHostViewQtDelegate
-{
+class RenderWidgetHostViewQtDelegateWidget : public QOpenGLWidget, public RenderWidgetHostViewQtDelegate {
+ Q_OBJECT
public:
RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0);
@@ -81,13 +81,17 @@ public:
virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
protected:
- bool event(QEvent *event);
- void resizeEvent(QResizeEvent *resizeEvent);
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+private slots:
+ void onWindowPosChanged();
+
private:
RenderWidgetHostViewQtDelegateClient *m_client;
// Put the root node first to make sure it gets destroyed after the SG renderer.
@@ -95,6 +99,7 @@ private:
QScopedPointer<QSGEngine> m_sgEngine;
QScopedPointer<QSGAbstractRenderer> m_sgRenderer;
bool m_isPopup;
+ QList<QMetaObject::Connection> m_windowConnections;
};
#endif