From 8edf8737ceaa4962fddb0c626f571d78bf90cb3a Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Mon, 4 Jul 2022 22:33:40 +0100 Subject: [PATCH] Port FallbackMouseGrabber to our own event filter abstraction No longer uses Qt's event filter directly --- src/private/DragController.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/private/DragController.cpp b/src/private/DragController.cpp index d97bf1a6..79988248 100644 --- a/src/private/DragController.cpp +++ b/src/private/DragController.cpp @@ -48,7 +48,7 @@ using namespace KDDockWidgets::Controllers; namespace KDDockWidgets { ///@brief Custom mouse grabber, for platforms that don't support grabbing the mouse -class FallbackMouseGrabber : public QObject /// clazy:exclude=missing-qobject-macro +class FallbackMouseGrabber : public QObject, public EventFilterInterface /// clazy:exclude=missing-qobject-macro { public: FallbackMouseGrabber(QObject *parent) @@ -62,7 +62,7 @@ public: { m_target = target; m_guard = target; - qGuiApp->installEventFilter(this); + Platform::instance()->installGlobalEventFilter(this); } void releaseMouse() @@ -75,22 +75,18 @@ public: m_target = nullptr; m_guard.clear(); - qGuiApp->removeEventFilter(this); + Platform::instance()->removeGlobalEventFilter(this); } - bool eventFilter(QObject *, QEvent *ev) override + bool onMouseEvent(View *, QMouseEvent *me) override { if (m_reentrancyGuard || !m_guard) return false; - if (QMouseEvent *me = mouseEvent(ev)) { - m_reentrancyGuard = true; - Platform::instance()->sendEvent(m_target, me); - m_reentrancyGuard = false; - return true; - } - - return false; + m_reentrancyGuard = true; + Platform::instance()->sendEvent(m_target, me); + m_reentrancyGuard = false; + return true; } bool m_reentrancyGuard = false;