diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2015-07-09 21:52:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-07-14 13:06:19 +0000 |
commit | 99e98f7bf6aec78fe0d647fb898e65d13ff522e4 (patch) | |
tree | 64a38d99e5f6287e80f92df1d9ac125cc2325b87 /src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp | |
parent | 8d6b933a971476abe91e72728d997aa5dd2a71be (diff) |
Add a backgroundColor property
This also allows setting a transparent color to see through
the web view's body if its background color isn't specified.
The color is initially held by the top API view and is pulled
by the WebContentsAdapter in order to set it on the RenderView.
Since both blink and our local compositors (in the QOpenGLWidget
case) need to know about this color, RWHVQt takes care of pushing
it to both. The former through an IPC message and the latter
directly on the RWHVQtDelegate.
Task-number: QTBUG-41960
Change-Id: Ie13317b2d087f5612ad9c5fb0e05ca3e91aec9af
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp')
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp | 16 |
1 files changed, 15 insertions, 1 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 dba37cea7..76ca8d354 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -59,6 +59,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende , m_rootNode(new QSGRootNode) , m_sgEngine(new QSGEngine) , m_isPopup(false) + , m_clearColor(Qt::white) { setFocusPolicy(Qt::StrongFocus); @@ -218,6 +219,19 @@ void RenderWidgetHostViewQtDelegateWidget::setTooltip(const QString &tooltip) setToolTip(wrappedTip); } +void RenderWidgetHostViewQtDelegateWidget::setClearColor(const QColor &color) +{ + m_clearColor = color; + // QOpenGLWidget is usually blended by punching holes into widgets + // above it to simulate the visual stacking order. If we want it to be + // transparent we have to throw away the proper stacking order and always + // blend the complete normal widgets backing store under it. + bool isTranslucent = color.alpha() < 255; + setAttribute(Qt::WA_AlwaysStackOnTop, isTranslucent); + setAttribute(Qt::WA_OpaquePaintEvent, !isTranslucent); + update(); +} + QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const { return m_client->inputMethodQuery(query); @@ -270,7 +284,7 @@ void RenderWidgetHostViewQtDelegateWidget::initializeGL() m_sgEngine->initialize(QOpenGLContext::currentContext()); m_sgRenderer.reset(m_sgEngine->createRenderer()); m_sgRenderer->setRootNode(m_rootNode.data()); - m_sgRenderer->setClearColor(Qt::white); + m_sgRenderer->setClearColor(m_clearColor); } void RenderWidgetHostViewQtDelegateWidget::paintGL() |