diff options
Diffstat (limited to 'src/compositor/extensions')
24 files changed, 151 insertions, 352 deletions
diff --git a/src/compositor/extensions/qwaylandivisurface.cpp b/src/compositor/extensions/qwaylandivisurface.cpp index 0ae488def..f1d58f739 100644 --- a/src/compositor/extensions/qwaylandivisurface.cpp +++ b/src/compositor/extensions/qwaylandivisurface.cpp @@ -40,7 +40,7 @@ #include "qwaylandivisurface.h" #include "qwaylandivisurface_p.h" #include "qwaylandiviapplication_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandivisurfaceintegration_p.h" #endif @@ -208,7 +208,7 @@ void QWaylandIviSurface::sendConfigure(const QSize &size) d->send_configure(size.width(), size.height()); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandIviSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::IviSurfaceIntegration(item); diff --git a/src/compositor/extensions/qwaylandivisurface.h b/src/compositor/extensions/qwaylandivisurface.h index 65d5bbc86..525ad9571 100644 --- a/src/compositor/extensions/qwaylandivisurface.h +++ b/src/compositor/extensions/qwaylandivisurface.h @@ -78,7 +78,7 @@ public: Q_INVOKABLE void sendConfigure(const QSize &size); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif 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 diff --git a/src/compositor/extensions/qwaylandquickshellintegration.h b/src/compositor/extensions/qwaylandquickshellintegration.h index e1a4c2384..00696681b 100644 --- a/src/compositor/extensions/qwaylandquickshellintegration.h +++ b/src/compositor/extensions/qwaylandquickshellintegration.h @@ -41,7 +41,6 @@ #define QWAYLANDQUICKSHELLINTEGRATION_H #include <QtCore/QObject> -#include <QtGui/QMouseEvent> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> QT_BEGIN_NAMESPACE @@ -50,25 +49,8 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject { Q_OBJECT public: - explicit QWaylandQuickShellIntegration(QObject *parent = nullptr); - - virtual bool touchEvent(QTouchEvent *event); - - virtual bool hoverEnterEvent(QHoverEvent *event); - virtual bool hoverLeaveEvent(QHoverEvent *event); - virtual bool hoverMoveEvent(QHoverEvent *event); - - virtual bool keyPressEvent(QKeyEvent *event); - virtual bool keyReleaseEvent(QKeyEvent *event); - - virtual bool mouseDoubleClickEvent(QMouseEvent *event); - virtual bool mouseMoveEvent(QMouseEvent *event); - virtual bool mousePressEvent(QMouseEvent *event); - virtual bool mouseReleaseEvent(QMouseEvent *event); - -#if QT_CONFIG(wheelevent) - virtual bool wheelEvent(QWheelEvent *event); -#endif + QWaylandQuickShellIntegration(QObject *parent = nullptr); + ~QWaylandQuickShellIntegration() override; }; QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp index 110c3d0a3..bda536017 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp @@ -96,7 +96,11 @@ QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QQuickItem *parent) QWaylandQuickShellSurfaceItem::~QWaylandQuickShellSurfaceItem() { Q_D(QWaylandQuickShellSurfaceItem); - delete d->m_shellIntegration; + + if (d->m_shellIntegration) { + removeEventFilter(d->m_shellIntegration); + delete d->m_shellIntegration; + } } /*! @@ -137,12 +141,15 @@ void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellS d->m_shellSurface = shellSurface; if (d->m_shellIntegration) { + removeEventFilter(d->m_shellIntegration); delete d->m_shellIntegration; d->m_shellIntegration = nullptr; } - if (shellSurface) + if (shellSurface) { d->m_shellIntegration = shellSurface->createIntegration(this); + installEventFilter(d->m_shellIntegration); + } emit shellSurfaceChanged(); } @@ -208,86 +215,6 @@ void QWaylandQuickShellSurfaceItem::setAutoCreatePopupItems(bool enabled) emit autoCreatePopupItemsChanged(); } -void QWaylandQuickShellSurfaceItem::touchEvent(QTouchEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->touchEvent(event)) - QWaylandQuickItem::touchEvent(event); -} - -void QWaylandQuickShellSurfaceItem::hoverEnterEvent(QHoverEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->hoverEnterEvent(event)) - QWaylandQuickItem::hoverEnterEvent(event); -} - -void QWaylandQuickShellSurfaceItem::hoverLeaveEvent(QHoverEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->hoverLeaveEvent(event)) - QWaylandQuickItem::hoverLeaveEvent(event); -} - -void QWaylandQuickShellSurfaceItem::hoverMoveEvent(QHoverEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->hoverMoveEvent(event)) - QWaylandQuickItem::hoverMoveEvent(event); -} - - -void QWaylandQuickShellSurfaceItem::keyPressEvent(QKeyEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->keyPressEvent(event)) - QWaylandQuickItem::keyPressEvent(event); -} - -void QWaylandQuickShellSurfaceItem::keyReleaseEvent(QKeyEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->keyReleaseEvent(event)) - QWaylandQuickItem::keyReleaseEvent(event); -} - -void QWaylandQuickShellSurfaceItem::mouseDoubleClickEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->mouseDoubleClickEvent(event)) - QWaylandQuickItem::mouseDoubleClickEvent(event); -} - -void QWaylandQuickShellSurfaceItem::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->mouseMoveEvent(event)) - QWaylandQuickItem::mouseMoveEvent(event); -} - -void QWaylandQuickShellSurfaceItem::mousePressEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->mousePressEvent(event)) - QWaylandQuickItem::mousePressEvent(event); -} - -void QWaylandQuickShellSurfaceItem::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->mouseReleaseEvent(event)) - QWaylandQuickItem::mouseReleaseEvent(event); -} - -#if QT_CONFIG(wheelevent) -void QWaylandQuickShellSurfaceItem::wheelEvent(QWheelEvent *event) -{ - Q_D(QWaylandQuickShellSurfaceItem); - if (!d->m_shellIntegration->wheelEvent(event)) - QWaylandQuickItem::wheelEvent(event); -} -#endif - /*! \class QWaylandQuickShellEventFilter \brief QWaylandQuickShellEventFilter implements a Wayland popup grab diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h index 73a4900bb..51c0425e6 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h @@ -75,24 +75,6 @@ Q_SIGNALS: protected: QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent); - - void touchEvent(QTouchEvent *event) override; - - void hoverEnterEvent(QHoverEvent *event) override; - void hoverLeaveEvent(QHoverEvent *event) override; - void hoverMoveEvent(QHoverEvent *event) override; - - void keyPressEvent(QKeyEvent *event) override; - void keyReleaseEvent(QKeyEvent *event) override; - - void mouseDoubleClickEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - -#if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent *event) override; -#endif }; QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandshellsurface.cpp b/src/compositor/extensions/qwaylandshellsurface.cpp index cb6d03646..7b59801e9 100644 --- a/src/compositor/extensions/qwaylandshellsurface.cpp +++ b/src/compositor/extensions/qwaylandshellsurface.cpp @@ -69,7 +69,7 @@ * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface */ -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) /*! * \fn QWaylandQuickShellIntegration *QWaylandShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) * diff --git a/src/compositor/extensions/qwaylandshellsurface.h b/src/compositor/extensions/qwaylandshellsurface.h index aca02e2fa..6b943f368 100644 --- a/src/compositor/extensions/qwaylandshellsurface.h +++ b/src/compositor/extensions/qwaylandshellsurface.h @@ -54,7 +54,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandComposit Q_OBJECT Q_PROPERTY(Qt::WindowType windowType READ windowType NOTIFY windowTypeChanged) public: -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; #endif QWaylandShellSurface(QWaylandObject *waylandObject) : QWaylandCompositorExtension(waylandObject) {} diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 8cd2c7310..ea228cab2 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -41,7 +41,7 @@ #include "qwaylandwlshell.h" #include "qwaylandwlshell_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandwlshellintegration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -587,7 +587,7 @@ void QWaylandWlShellSurface::sendPopupDone() d->send_popup_done(); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::WlShellIntegration(item); diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h index 421888000..b37773e28 100644 --- a/src/compositor/extensions/qwaylandwlshell.h +++ b/src/compositor/extensions/qwaylandwlshell.h @@ -140,7 +140,7 @@ public: Q_INVOKABLE void sendConfigure(const QSize &size, ResizeEdge edges); Q_INVOKABLE void sendPopupDone(); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index b732069c4..724580e24 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -289,7 +289,19 @@ void WlShellIntegration::adjustOffsetForNextFrame(const QPointF &offset) moveItem->setPosition(moveItem->position() + m_item->mapFromSurface(offset)); } -bool WlShellIntegration::mouseMoveEvent(QMouseEvent *event) +bool WlShellIntegration::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseMoveEvent(mouseEvent); + } else if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseReleaseEvent(mouseEvent); + } + return QWaylandQuickShellIntegration::eventFilter(object, event); +} + +bool WlShellIntegration::filterMouseMoveEvent(QMouseEvent *event) { if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); @@ -318,7 +330,7 @@ bool WlShellIntegration::mouseMoveEvent(QMouseEvent *event) return false; } -bool WlShellIntegration::mouseReleaseEvent(QMouseEvent *event) +bool WlShellIntegration::filterMouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); if (grabberState != GrabberState::Default) { diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index 8af54dfc4..eb23a62fc 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration_p.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -65,8 +65,9 @@ class WlShellIntegration : public QWaylandQuickShellIntegration public: WlShellIntegration(QWaylandQuickShellSurfaceItem *item); ~WlShellIntegration() override; - bool mouseMoveEvent(QMouseEvent *event) override; - bool mouseReleaseEvent(QMouseEvent *event) override; + +protected: + bool eventFilter(QObject *object, QEvent *event) override; private Q_SLOTS: void handleStartMove(QWaylandSeat *seat); @@ -130,6 +131,9 @@ private: QPointF normalPosition; QPointF finalPosition; + + bool filterMouseMoveEvent(QMouseEvent *event); + bool filterMouseReleaseEvent(QMouseEvent *event); }; } diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index eece3f3d6..1b8a3c2e2 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -37,7 +37,7 @@ #include "qwaylandxdgshell.h" #include "qwaylandxdgshell_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandxdgshellintegration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -693,7 +693,7 @@ QWaylandXdgSurface *QWaylandXdgSurface::fromResource(wl_resource *resource) return nullptr; } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { Q_D(const QWaylandXdgSurface); diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h index f45038eb9..2e3e28180 100644 --- a/src/compositor/extensions/qwaylandxdgshell.h +++ b/src/compositor/extensions/qwaylandxdgshell.h @@ -119,7 +119,7 @@ public: static QByteArray interfaceName(); static QWaylandXdgSurface *fromResource(::wl_resource *resource); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp index 3de52944b..336ede3cc 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp @@ -77,7 +77,19 @@ XdgToplevelIntegration::XdgToplevelIntegration(QWaylandQuickShellSurfaceItem *it connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelIntegration::handleToplevelDestroyed); } -bool XdgToplevelIntegration::mouseMoveEvent(QMouseEvent *event) +bool XdgToplevelIntegration::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseMoveEvent(mouseEvent); + } else if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseReleaseEvent(mouseEvent); + } + return QWaylandQuickShellIntegration::eventFilter(object, event); +} + +bool XdgToplevelIntegration::filterMouseMoveEvent(QMouseEvent *event) { if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); @@ -105,7 +117,7 @@ bool XdgToplevelIntegration::mouseMoveEvent(QMouseEvent *event) return false; } -bool XdgToplevelIntegration::mouseReleaseEvent(QMouseEvent *event) +bool XdgToplevelIntegration::filterMouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); diff --git a/src/compositor/extensions/qwaylandxdgshellintegration_p.h b/src/compositor/extensions/qwaylandxdgshellintegration_p.h index 34e3873d5..cd6bad572 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellintegration_p.h @@ -63,8 +63,9 @@ class XdgToplevelIntegration : public QWaylandQuickShellIntegration Q_OBJECT public: XdgToplevelIntegration(QWaylandQuickShellSurfaceItem *item); - bool mouseMoveEvent(QMouseEvent *event) override; - bool mouseReleaseEvent(QMouseEvent *event) override; + +protected: + bool eventFilter(QObject *object, QEvent *event) override; private Q_SLOTS: void handleStartMove(QWaylandSeat *seat); @@ -120,6 +121,9 @@ private: // will be hooked to geometry-changed or available- // geometry-changed. } nonwindowedState; + + bool filterMouseMoveEvent(QMouseEvent *event); + bool filterMouseReleaseEvent(QMouseEvent *event); }; class XdgPopupIntegration : public QWaylandQuickShellIntegration diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp index a40c21682..e38e68eb0 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp @@ -40,7 +40,7 @@ #include "qwaylandxdgshellv5.h" #include "qwaylandxdgshellv5_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandxdgshellv5integration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -1317,7 +1317,7 @@ uint QWaylandXdgSurfaceV5::sendResizing(const QSize &maxSize) return sendConfigure(maxSize, conf.states); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::XdgShellV5Integration(item); @@ -1517,7 +1517,7 @@ void QWaylandXdgPopupV5::sendPopupDone() d->send_popup_done(); } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgPopupV5::createIntegration(QWaylandQuickShellSurfaceItem *item) { return new QtWayland::XdgPopupV5Integration(item); diff --git a/src/compositor/extensions/qwaylandxdgshellv5.h b/src/compositor/extensions/qwaylandxdgshellv5.h index f989d04c7..66e9ceb05 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5.h +++ b/src/compositor/extensions/qwaylandxdgshellv5.h @@ -171,7 +171,7 @@ public: Q_INVOKABLE uint sendFullscreen(const QSize &size); Q_INVOKABLE uint sendResizing(const QSize &maxSize); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif @@ -243,7 +243,7 @@ public: Q_INVOKABLE void sendPopupDone(); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp index 1d63632a3..4907a0611 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp @@ -82,7 +82,19 @@ XdgShellV5Integration::~XdgShellV5Integration() m_item->setSurface(nullptr); } -bool XdgShellV5Integration::mouseMoveEvent(QMouseEvent *event) +bool XdgShellV5Integration::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseMoveEvent(mouseEvent); + } else if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseReleaseEvent(mouseEvent); + } + return QWaylandQuickShellIntegration::eventFilter(object, event); +} + +bool XdgShellV5Integration::filterMouseMoveEvent(QMouseEvent *event) { if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); @@ -110,7 +122,7 @@ bool XdgShellV5Integration::mouseMoveEvent(QMouseEvent *event) return false; } -bool XdgShellV5Integration::mouseReleaseEvent(QMouseEvent *event) +bool XdgShellV5Integration::filterMouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h b/src/compositor/extensions/qwaylandxdgshellv5integration_p.h index 5d0e1e142..99983c866 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellv5integration_p.h @@ -64,8 +64,9 @@ class XdgShellV5Integration : public QWaylandQuickShellIntegration public: XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item); ~XdgShellV5Integration() override; - bool mouseMoveEvent(QMouseEvent *event) override; - bool mouseReleaseEvent(QMouseEvent *event) override; + +protected: + bool eventFilter(QObject *object, QEvent *event) override; private Q_SLOTS: void handleStartMove(QWaylandSeat *seat); @@ -108,6 +109,9 @@ private: QSize initialWindowSize; QPointF initialPosition; } maximizeState; + + bool filterMouseMoveEvent(QMouseEvent *event); + bool filterMouseReleaseEvent(QMouseEvent *event); }; class XdgPopupV5Integration : public QWaylandQuickShellIntegration diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp index 96d6f5509..934dccb06 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp @@ -37,7 +37,7 @@ #include "qwaylandxdgshellv6.h" #include "qwaylandxdgshellv6_p.h" -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) #include "qwaylandxdgshellv6integration_p.h" #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> @@ -698,7 +698,7 @@ QWaylandXdgSurfaceV6 *QWaylandXdgSurfaceV6::fromResource(wl_resource *resource) return nullptr; } -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *QWaylandXdgSurfaceV6::createIntegration(QWaylandQuickShellSurfaceItem *item) { Q_D(const QWaylandXdgSurfaceV6); diff --git a/src/compositor/extensions/qwaylandxdgshellv6.h b/src/compositor/extensions/qwaylandxdgshellv6.h index 64c82306c..71f82521a 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6.h +++ b/src/compositor/extensions/qwaylandxdgshellv6.h @@ -119,7 +119,7 @@ public: static QByteArray interfaceName(); static QWaylandXdgSurfaceV6 *fromResource(::wl_resource *resource); -#ifdef QT_WAYLAND_COMPOSITOR_QUICK +#if QT_CONFIG(wayland_compositor_quick) QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; #endif diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp index 66dbc6841..e424af193 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp @@ -77,7 +77,19 @@ XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelV6Integration::handleToplevelDestroyed); } -bool XdgToplevelV6Integration::mouseMoveEvent(QMouseEvent *event) +bool XdgToplevelV6Integration::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseMoveEvent(mouseEvent); + } else if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + return filterMouseReleaseEvent(mouseEvent); + } + return QWaylandQuickShellIntegration::eventFilter(object, event); +} + +bool XdgToplevelV6Integration::filterMouseMoveEvent(QMouseEvent *event) { if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); @@ -105,7 +117,7 @@ bool XdgToplevelV6Integration::mouseMoveEvent(QMouseEvent *event) return false; } -bool XdgToplevelV6Integration::mouseReleaseEvent(QMouseEvent *event) +bool XdgToplevelV6Integration::filterMouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h index 049b901c9..9df2885f1 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h @@ -63,8 +63,9 @@ class XdgToplevelV6Integration : public QWaylandQuickShellIntegration Q_OBJECT public: XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item); - bool mouseMoveEvent(QMouseEvent *event) override; - bool mouseReleaseEvent(QMouseEvent *event) override; + +protected: + bool eventFilter(QObject *object, QEvent *event) override; private Q_SLOTS: void handleStartMove(QWaylandSeat *seat); @@ -120,6 +121,9 @@ private: // will be hooked to geometry-changed or available- // geometry-changed. } nonwindowedState; + + bool filterMouseMoveEvent(QMouseEvent *event); + bool filterMouseReleaseEvent(QMouseEvent *event); }; class XdgPopupV6Integration : public QWaylandQuickShellIntegration |