| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qwaylandquickshellintegration.h" |
| 5 | |
| 6 | /*! |
| 7 | * \class QWaylandQuickShellIntegration |
| 8 | * \inmodule QtWaylandCompositor |
| 9 | * \since 5.14 |
| 10 | * \brief Provides support for shell surface integration with QtQuick. |
| 11 | * |
| 12 | * Shell surface implementations should inherit from this class in order to provide |
| 13 | * an integration between the shell surface and QtQuick. |
| 14 | * |
| 15 | * Shell integration is installed as an event filter for a QWaylandQuickShellSurfaceItem. |
| 16 | * Reimplement the event filter method and return \c true when you want to filter the |
| 17 | * event out, otherwise return \c false. |
| 18 | * |
| 19 | * Example: |
| 20 | * |
| 21 | * \code |
| 22 | * class MyShellIntegration : public QWaylandQuickShellIntegration |
| 23 | * { |
| 24 | * Q_OBJECT |
| 25 | * public: |
| 26 | * MyShellIntegration(QObject *parent = nullptr); |
| 27 | * |
| 28 | * protected: |
| 29 | * bool eventFilter(QObject *object, QEvent *event) override; |
| 30 | * }; |
| 31 | * |
| 32 | * MyShellIntegration::MyShellIntegration(QObject *parent) |
| 33 | * : QWaylandQuickShellIntegration(parent) |
| 34 | * { |
| 35 | * } |
| 36 | * |
| 37 | * bool MyShellIntegration::eventFilter(QObject *object, QEvent *event) |
| 38 | * { |
| 39 | * QWaylandQuickShellSurfaceItem *shellSurfaceItem = qobject_cast<QWaylandQuickShellSurfaceItem *>(object); |
| 40 | * if (!shellSurfaceItem) |
| 41 | * return QWaylandQuickShellIntegration::eventFilter(object, event); |
| 42 | * |
| 43 | * if (event->type() == QEvent::MouseMove) { |
| 44 | * QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); |
| 45 | * qDebug() << "Mouse moved on" << shellSurfaceItem << "pos:" << mouseEvent->pos(); |
| 46 | * return true; |
| 47 | * } |
| 48 | * |
| 49 | * return QWaylandQuickShellIntegration::eventFilter(object, event); |
| 50 | * } |
| 51 | * \endcode |
| 52 | * |
| 53 | * \sa QWaylandQuickShellSurfaceItem |
| 54 | * \sa QObject::eventFilter() |
| 55 | */ |
| 56 | |
| 57 | QT_BEGIN_NAMESPACE |
| 58 | |
| 59 | QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) |
| 60 | : QObject(parent) |
| 61 | { |
| 62 | } |
| 63 | |
| 64 | QWaylandQuickShellIntegration::~QWaylandQuickShellIntegration() |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | QT_END_NAMESPACE |
| 69 | |
| 70 | #include "moc_qwaylandquickshellintegration.cpp" |
| 71 | |