summaryrefslogtreecommitdiffstats
path: root/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp')
-rw-r--r--src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp110
1 files changed, 32 insertions, 78 deletions
diff --git a/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp
index 7cae38b2e..090b09281 100644
--- a/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -1,46 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "render_widget_host_view_qt_delegate_quick.h"
-#include "render_widget_host_view_qt_delegate_quickwindow.h"
-
-#include <QtQuick/qquickitem.h>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "render_widget_host_view_qt_delegate_quickwindow_p.h"
+
+#include "api/qquickwebengineview_p_p.h"
namespace QtWebEngineCore {
@@ -68,14 +31,19 @@ static inline QPointF transformPoint(const QPointF &point, const QTransform &tra
}
RenderWidgetHostViewQtDelegateQuickWindow::RenderWidgetHostViewQtDelegateQuickWindow(
- RenderWidgetHostViewQtDelegateQuick *realDelegate, QWindow *parent)
+ RenderWidgetHostViewQtDelegateItem *realDelegate, QWindow *parent)
: QQuickWindow(parent), m_realDelegate(realDelegate), m_virtualParent(nullptr), m_rotated(false)
{
setFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
+ realDelegate->setParentItem(contentItem());
}
RenderWidgetHostViewQtDelegateQuickWindow::~RenderWidgetHostViewQtDelegateQuickWindow()
{
+ if (m_realDelegate) {
+ m_realDelegate->setWidgetDelegate(nullptr);
+ m_realDelegate->setParentItem(nullptr);
+ }
}
void RenderWidgetHostViewQtDelegateQuickWindow::setVirtualParent(QQuickItem *virtualParent)
@@ -86,9 +54,9 @@ void RenderWidgetHostViewQtDelegateQuickWindow::setVirtualParent(QQuickItem *vir
// rect is window geometry in form of parent window offset + offset in scene coordinates
// chromium knows nothing about local transformation
-void RenderWidgetHostViewQtDelegateQuickWindow::initAsPopup(const QRect &rect)
+void RenderWidgetHostViewQtDelegateQuickWindow::InitAsPopup(const QRect &rect)
{
- m_rotated = m_virtualParent->parentItem()->rotation() > 0;
+ m_rotated = m_virtualParent->rotation() > 0 || m_virtualParent->parentItem()->rotation() > 0;
if (m_rotated) {
// code below tries to cover the case where webengine view is rotated,
// the code assumes the rotation is in the form of 90, 180, 270 degrees
@@ -104,7 +72,6 @@ void RenderWidgetHostViewQtDelegateQuickWindow::initAsPopup(const QRect &rect)
QPointF br = transformPoint(rect.bottomRight(), transform, offset, m_virtualParent);
QRectF popupRect(tl, br);
popupRect = popupRect.normalized();
- m_realDelegate->setSize(rect.size());
// include offset from parent window
popupRect.moveTo(popupRect.topLeft() - offset);
setGeometry(popupRect.adjusted(0, 0, 1, 1).toRect());
@@ -115,64 +82,51 @@ void RenderWidgetHostViewQtDelegateQuickWindow::initAsPopup(const QRect &rect)
m_realDelegate->setTransformOrigin(QQuickItem::Center);
m_realDelegate->setRotation(m_virtualParent->parentItem()->rotation());
} else {
- m_realDelegate->setSize(rect.size());
QRect geometry(rect);
geometry.moveTo(rect.topLeft() - getOffset(m_virtualParent));
setGeometry(geometry);
}
+ m_realDelegate->show();
raise();
show();
}
-QRectF RenderWidgetHostViewQtDelegateQuickWindow::viewGeometry() const
-{
- return m_rotated ? m_rect : geometry();
-}
-
-QRect RenderWidgetHostViewQtDelegateQuickWindow::windowGeometry() const
-{
- return m_rotated ? m_rect : frameGeometry();
-}
-
-void RenderWidgetHostViewQtDelegateQuickWindow::show()
+void RenderWidgetHostViewQtDelegateQuickWindow::Resize(int width, int height)
{
- QQuickWindow::show();
- m_realDelegate->show();
+ if (!m_rotated)
+ QQuickWindow::resize(width, height);
}
-void RenderWidgetHostViewQtDelegateQuickWindow::hide()
+void RenderWidgetHostViewQtDelegateQuickWindow::MoveWindow(const QPoint &screenPos)
{
- QQuickWindow::hide();
- m_realDelegate->hide();
+ if (!m_rotated)
+ QQuickWindow::setPosition(screenPos - getOffset(m_virtualParent));
}
-bool RenderWidgetHostViewQtDelegateQuickWindow::isVisible() const
+void RenderWidgetHostViewQtDelegateQuickWindow::SetClearColor(const QColor &color)
{
- return QQuickWindow::isVisible();
+ QQuickWindow::setColor(color);
}
-QWindow *RenderWidgetHostViewQtDelegateQuickWindow::window() const
+bool RenderWidgetHostViewQtDelegateQuickWindow::ActiveFocusOnPress()
{
- return const_cast<RenderWidgetHostViewQtDelegateQuickWindow*>(this);
+ return false;
}
-void RenderWidgetHostViewQtDelegateQuickWindow::updateCursor(const QCursor &cursor)
+void RenderWidgetHostViewQtDelegateQuickWindow::Bind(QtWebEngineCore::WebContentsAdapterClient *client)
{
- setCursor(cursor);
+ QQuickWebEngineViewPrivate::bindViewAndDelegateItem(
+ static_cast<QQuickWebEngineViewPrivate *>(client), m_realDelegate.data());
}
-void RenderWidgetHostViewQtDelegateQuickWindow::resize(int width, int height)
+void RenderWidgetHostViewQtDelegateQuickWindow::Unbind()
{
- if (!m_rotated) {
- QQuickWindow::resize(width, height);
- m_realDelegate->resize(width, height);
- }
+ QQuickWebEngineViewPrivate::bindViewAndDelegateItem(nullptr, m_realDelegate.data());
}
-void RenderWidgetHostViewQtDelegateQuickWindow::move(const QPoint &screenPos)
+void RenderWidgetHostViewQtDelegateQuickWindow::Destroy()
{
- if (!m_rotated)
- QQuickWindow::setPosition(screenPos - getOffset(m_virtualParent));
+ deleteLater();
}
} // namespace QtWebEngineCore