summaryrefslogtreecommitdiffstats
path: root/src/input/backend
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-10-08 06:58:13 +0100
committerMike Krus <mike.krus@kdab.com>2019-10-11 07:23:26 +0100
commitfb624a684e816fb8100de6e1a7ab85d15cc36c3a (patch)
treeae6fc022ae3f2e1bbff17169362db5ee56f55d10 /src/input/backend
parent02ec5db08128030ce0891ebbd86fccd0b82e3c0c (diff)
Update MouseEventDispatcherJob to use direct sync
Change-Id: I972765a3937e580271127d7aa7e3cb76d76de818 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/backend')
-rw-r--r--src/input/backend/mouseeventdispatcherjob.cpp57
-rw-r--r--src/input/backend/mouseeventdispatcherjob_p.h8
-rw-r--r--src/input/backend/mousehandler.cpp20
-rw-r--r--src/input/backend/mousehandler_p.h4
4 files changed, 45 insertions, 44 deletions
diff --git a/src/input/backend/mouseeventdispatcherjob.cpp b/src/input/backend/mouseeventdispatcherjob.cpp
index 4bd3e93c3..0ee6862fb 100644
--- a/src/input/backend/mouseeventdispatcherjob.cpp
+++ b/src/input/backend/mouseeventdispatcherjob.cpp
@@ -38,7 +38,9 @@
****************************************************************************/
#include "mouseeventdispatcherjob_p.h"
-
+#include <Qt3DCore/private/qaspectmanager_p.h>
+#include <Qt3DInput/qmousehandler.h>
+#include <Qt3DInput/private/qmousehandler_p.h>
#include <Qt3DInput/private/inputhandler_p.h>
#include <Qt3DInput/private/inputmanagers_p.h>
#include <Qt3DInput/private/job_common_p.h>
@@ -49,21 +51,37 @@ QT_BEGIN_NAMESPACE
namespace Qt3DInput {
namespace Input {
+class MouseEventDispatcherJobPrivate : public Qt3DCore::QAspectJobPrivate
+{
+public:
+ MouseEventDispatcherJobPrivate() { }
+ ~MouseEventDispatcherJobPrivate() override { }
+
+ void postFrame(Qt3DCore::QAspectManager *manager) override;
+
+ Qt3DCore::QNodeId m_mouseInput;
+ QList<QT_PREPEND_NAMESPACE(QMouseEvent)> m_mouseEvents;
+#if QT_CONFIG(wheelevent)
+ QList<QT_PREPEND_NAMESPACE(QWheelEvent)> m_wheelEvents;
+#endif
+};
+
MouseEventDispatcherJob::MouseEventDispatcherJob(Qt3DCore::QNodeId input,
const QList<QT_PREPEND_NAMESPACE (QMouseEvent)> &mouseEvents
#if QT_CONFIG(wheelevent)
, const QList<QT_PREPEND_NAMESPACE (QWheelEvent)> &wheelEvents
#endif
)
- : QAspectJob()
+ : QAspectJob(*new MouseEventDispatcherJobPrivate)
, m_inputHandler(nullptr)
- , m_mouseInput(input)
- , m_mouseEvents(mouseEvents)
+{
+ Q_D(MouseEventDispatcherJob);
+ d->m_mouseInput = input;
+ d->m_mouseEvents = mouseEvents;
#if QT_CONFIG(wheelevent)
- , m_wheelEvents(wheelEvents)
+ d->m_wheelEvents = wheelEvents;
#endif
-{
- SET_JOB_RUN_STAT_TYPE(this, JobTypes::MouseEventDispatcher, 0);
+ SET_JOB_RUN_STAT_TYPE(this, JobTypes::MouseEventDispatcher, 0)
}
void MouseEventDispatcherJob::setInputHandler(InputHandler *handler)
@@ -73,16 +91,25 @@ void MouseEventDispatcherJob::setInputHandler(InputHandler *handler)
void MouseEventDispatcherJob::run()
{
- MouseHandler *input = m_inputHandler->mouseInputManager()->lookupResource(m_mouseInput);
- if (input) {
- // Send mouse and wheel events to frontend
- for (const QT_PREPEND_NAMESPACE(QMouseEvent) &e : m_mouseEvents)
- input->mouseEvent(QMouseEventPtr::create(e));
+ // NOP
+}
+
+void MouseEventDispatcherJobPrivate::postFrame(Qt3DCore::QAspectManager *manager)
+{
+ QMouseHandler *node = qobject_cast<QMouseHandler *>(manager->lookupNode(m_mouseInput));
+ if (!node)
+ return;
+
+ QMouseHandlerPrivate *dnode = static_cast<QMouseHandlerPrivate *>(QMouseHandlerPrivate::get(node));
+
+ for (const QT_PREPEND_NAMESPACE(QMouseEvent) &e : m_mouseEvents)
+ dnode->mouseEvent(QMouseEventPtr::create(e));
#if QT_CONFIG(wheelevent)
- for (const QT_PREPEND_NAMESPACE(QWheelEvent) &e : m_wheelEvents)
- input->wheelEvent(QWheelEventPtr::create(e));
-#endif
+ for (const QT_PREPEND_NAMESPACE(QWheelEvent) &e : m_wheelEvents) {
+ QWheelEvent we(e);
+ emit node->wheel(&we);
}
+#endif
}
} // namespace Input
diff --git a/src/input/backend/mouseeventdispatcherjob_p.h b/src/input/backend/mouseeventdispatcherjob_p.h
index 8abeccfb4..696d60da4 100644
--- a/src/input/backend/mouseeventdispatcherjob_p.h
+++ b/src/input/backend/mouseeventdispatcherjob_p.h
@@ -61,6 +61,7 @@ namespace Qt3DInput {
namespace Input {
class InputHandler;
+class MouseEventDispatcherJobPrivate;
class MouseEventDispatcherJob : public Qt3DCore::QAspectJob
{
@@ -75,12 +76,9 @@ public:
void run() final;
private:
+ Q_DECLARE_PRIVATE(MouseEventDispatcherJob)
+
InputHandler *m_inputHandler;
- const Qt3DCore::QNodeId m_mouseInput;
- const QList<QT_PREPEND_NAMESPACE(QMouseEvent)> m_mouseEvents;
-#if QT_CONFIG(wheelevent)
- const QList<QT_PREPEND_NAMESPACE(QWheelEvent)> m_wheelEvents;
-#endif
};
} // namespace Input
diff --git a/src/input/backend/mousehandler.cpp b/src/input/backend/mousehandler.cpp
index e0b0f1e7f..46bd273d6 100644
--- a/src/input/backend/mousehandler.cpp
+++ b/src/input/backend/mousehandler.cpp
@@ -75,26 +75,6 @@ void MouseHandler::setInputHandler(InputHandler *handler)
m_inputHandler = handler;
}
-void MouseHandler::mouseEvent(const QMouseEventPtr &event)
-{
- auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
- e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
- e->setPropertyName("mouse");
- e->setValue(QVariant::fromValue(event));
- notifyObservers(e);
-}
-
-#if QT_CONFIG(wheelevent)
-void MouseHandler::wheelEvent(const QWheelEventPtr &event)
-{
- auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
- e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
- e->setPropertyName("wheel");
- e->setValue(QVariant::fromValue(event));
- notifyObservers(e);
-}
-#endif
-
void MouseHandler::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
BackendNode::syncFromFrontEnd(frontEnd, firstTime);
diff --git a/src/input/backend/mousehandler_p.h b/src/input/backend/mousehandler_p.h
index dc1e210ac..693c42471 100644
--- a/src/input/backend/mousehandler_p.h
+++ b/src/input/backend/mousehandler_p.h
@@ -69,10 +69,6 @@ public:
Qt3DCore::QNodeId mouseDevice() const;
void setInputHandler(InputHandler *handler);
- void mouseEvent(const QMouseEventPtr &event);
-#if QT_CONFIG(wheelevent)
- void wheelEvent(const QWheelEventPtr &event);
-#endif
protected:
void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;