aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickdeliveryagent_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-14 20:09:57 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-02-25 10:31:37 +0100
commitf35afe3eeaa460cb5e96171fb8a43fdf52c8761c (patch)
tree32b5c087a30a5dc455b8505415b0372c661f24cd /src/quick/util/qquickdeliveryagent_p.h
parent4853b3a7d50c20ad00a2780b8d11a0f9c38462ae (diff)
Move event delivery from QQWindow to QQuickDeliveryAgent
QQuickWindow owns QQuickRootItem which owns QQuickDeliveryAgent, so for every window there's an object responsible for event delivery, while the window itself is mainly responsible for rendering (separation of concerns). However, QQuickRootItem and QQuickDeliveryAgent can now be used in cases where the scene doesn't directly belong to a window, such as when a Qt Quick sub-scene is mapped somewhere into a Qt Quick 3D scene. In that case, we must remember which delivery agent was in use at the time when a QEventPoint is grabbed and deliver subsequent updates via the same DA. There's also a QQuickDeliveryAgent::Transform abstraction which subscene-management code (such as QQuick3DViewport) can implement, to provide a formula to map the window's scene coordinates to subscene coordinates; if defined, it will be used during delivery of subsequent updates to existing grabbers. Task-number: QTBUG-84870 Change-Id: I70b433f7ebb05d2e60214ff3192e05da0aa84a42 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 68c103225f4e8bd6c1b18ef547108fd60f398c0f) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quick/util/qquickdeliveryagent_p.h')
-rw-r--r--src/quick/util/qquickdeliveryagent_p.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/quick/util/qquickdeliveryagent_p.h b/src/quick/util/qquickdeliveryagent_p.h
new file mode 100644
index 0000000000..41b3a5390b
--- /dev/null
+++ b/src/quick/util/qquickdeliveryagent_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick 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$
+**
+****************************************************************************/
+
+#ifndef QQUICKDELIVERYAGENT_P_H
+#define QQUICKDELIVERYAGENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qtquickglobal_p.h>
+
+#include <QtQml/qqml.h>
+#include <QtQml/private/qqmlglobal_p.h>
+
+#include <QtCore/qobject.h>
+#include <QtGui/qevent.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickItem;
+class QQuickDeliveryAgentPrivate;
+
+class Q_QUICK_EXPORT QQuickDeliveryAgent : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickDeliveryAgent)
+
+public:
+ struct Q_QUICK_EXPORT Transform
+ {
+ virtual ~Transform();
+ virtual QPointF map(const QPointF &point) = 0;
+ };
+
+ explicit QQuickDeliveryAgent(QQuickItem *rootItem);
+ virtual ~QQuickDeliveryAgent();
+
+ static QQuickDeliveryAgent *grabberAgent(QPointerEvent *pe, const QEventPoint &pt);
+
+ QQuickItem *rootItem() const;
+
+ void setSceneTransform(Transform *transform);
+ bool event(QEvent *ev) override;
+
+Q_SIGNALS:
+
+private:
+ Q_DISABLE_COPY(QQuickDeliveryAgent)
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickDeliveryAgent *da);
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QQUICKDELIVERYAGENT_P_H