diff options
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 | 25 |
1 files changed, 22 insertions, 3 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 3d7237367..9871ecfb1 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); @@ -138,14 +139,12 @@ void RenderWidgetHostViewQtDelegateWidget::show() // want to show anything else than popups as top-level. if (parent() || m_isPopup) { QOpenGLWidget::show(); - m_client->notifyShown(); } } void RenderWidgetHostViewQtDelegateWidget::hide() { QOpenGLWidget::hide(); - m_client->notifyHidden(); } bool RenderWidgetHostViewQtDelegateWidget::isVisible() const @@ -218,6 +217,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); @@ -243,6 +255,13 @@ void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event) m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged()))); } m_client->windowChanged(); + m_client->notifyShown(); +} + +void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event) +{ + QOpenGLWidget::hideEvent(event); + m_client->notifyHidden(); } bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) @@ -270,7 +289,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); // When RenderWidgetHostViewQt::GetScreenInfo is called for the first time, the associated // QWindow is NULL, and the screen device pixel ratio can not be queried. |