diff options
Diffstat (limited to 'src/compositor/extensions/qwaylandquickshellintegration.cpp')
-rw-r--r-- | src/compositor/extensions/qwaylandquickshellintegration.cpp | 238 |
1 files changed, 41 insertions, 197 deletions
diff --git a/src/compositor/extensions/qwaylandquickshellintegration.cpp b/src/compositor/extensions/qwaylandquickshellintegration.cpp index 961b7b111..d56d6c22a 100644 --- a/src/compositor/extensions/qwaylandquickshellintegration.cpp +++ b/src/compositor/extensions/qwaylandquickshellintegration.cpp @@ -48,8 +48,46 @@ * Shell surface implementations should inherit from this class in order to provide * an integration between the shell surface and QtQuick. * - * \sa QWaylandShellSurface - * \sa QWaylandShellSurfaceItem + * Shell integration is installed as an event filter for a QWaylandQuickShellSurfaceItem. + * Reimplement the event filter method and return \c true when you want to filter the + * event out, otherwise return \c false. + * + * Example: + * + * \code + * class MyShellIntegration : public QWaylandQuickShellIntegration + * { + * Q_OBJECT + * public: + * MyShellIntegration(QObject *parent = nullptr); + * + * protected: + * bool eventFilter(QObject *object, QEvent *event) override; + * }; + * + * MyShellIntegration::MyShellIntegration(QObject *parent) + * : QWaylandQuickShellIntegration(parent) + * { + * } + * + * bool MyShellIntegration::eventFilter(QObject *object, QEvent *event) + * { + * QWaylandQuickShellSurfaceItem *shellSurfaceItem = qobject_cast<QWaylandQuickShellSurfaceItem *>(object); + * if (!shellSurfaceItem) + * return QWaylandQuickShellIntegration::eventFilter(object, event); + * + * if (event->type() == QEvent::MouseMove) { + * QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + * qDebug() << "Mouse moved on" << shellSurfaceItem << "pos:" << mouseEvent->pos(); + * return true; + * } + * + * return QWaylandQuickShellIntegration::eventFilter(object, event); + * } + * \endcode + * + * \sa QWaylandQuickShellSurfaceItem + * \sa QObject::eventFilter() */ QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) @@ -57,200 +95,6 @@ QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) { } -/*! - * This method can be reimplemented in a subclass to receive touch events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::touchEvent() - */ -bool QWaylandQuickShellIntegration::touchEvent(QTouchEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive hover-enter events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Hover events are only provided if \l {QWaylandQuickShellSurfaceItem::} {acceptHoverEvents()} - * is \a true. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::hoverEnterEvent() - */ -bool QWaylandQuickShellIntegration::hoverEnterEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive hover-leave events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Hover events are only provided if \l {QWaylandQuickShellSurfaceItem::} {acceptHoverEvents()} - * is \a true. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::hoverLeaveEvent() - */ -bool QWaylandQuickShellIntegration::hoverLeaveEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive hover-move events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Hover events are only provided if \l {QWaylandQuickShellSurfaceItem::} {acceptHoverEvents()} - * is \a true. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::hoverMoveEvent() - */ -bool QWaylandQuickShellIntegration::hoverMoveEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive key press events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::keyPressEvent() - */ -bool QWaylandQuickShellIntegration::keyPressEvent(QKeyEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive key release events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::keyReleaseEvent() - */ -bool QWaylandQuickShellIntegration::keyReleaseEvent(QKeyEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive mouse double click events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::mouseDoubleClickEvent() - */ -bool QWaylandQuickShellIntegration::mouseDoubleClickEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive mouse move events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::mouseMoveEvent() - */ -bool QWaylandQuickShellIntegration::mouseMoveEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive mouse press events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::mousePressEvent() - */ -bool QWaylandQuickShellIntegration::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - return false; -} - -/*! - * This method can be reimplemented in a subclass to receive mouse release events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::mouseReleaseEvent() - */ -bool QWaylandQuickShellIntegration::mouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - return false; -} - -#if QT_CONFIG(wheelevent) -/*! - * This method can be reimplemented in a subclass to receive wheel events - * for a shell surface. - * - * The event information is provided by the \a event parameter. - * - * Return \a false if you want QWaylandQuickShellSurfaceItem to handle - * the event. - * - * \sa QWaylandQuickShellSurfaceItem::wheelEvent() - */ -bool QWaylandQuickShellIntegration::wheelEvent(QWheelEvent *event) +QWaylandQuickShellIntegration::~QWaylandQuickShellIntegration() { - Q_UNUSED(event); - return false; } -#endif |