summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-11-04 22:10:35 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-11-07 06:24:38 +0100
commit9a1a15b42fb526ad4f80944afb7761bfff1b5c9d (patch)
tree058dd55dff01b3d6a429ff863132e33c05d019be /src/gui/kernel
parentbdec189ecbc2cabbfa803a571b49533f190f053d (diff)
Introduce QEvent::isSinglePointEvent()
This makes high-level event dispatching easier: for example we often need to cast an event to access getters like button() and buttons(). We can so far assume that any QPointerEvent that is not a QTouchEvent is a QSinglePointEvent; but more explicit type-checking looks safer. Implemented in a similar way as c7f727996909338c3689396160f3060480521846. Change-Id: I980d759e2a7538b6b30fd3bdc3be0c351ec6c246 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qevent.cpp19
-rw-r--r--src/gui/kernel/qevent.h5
2 files changed, 21 insertions, 3 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 9d27961071..5e9643d82f 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -164,6 +164,13 @@ QInputEvent::QInputEvent(QEvent::Type type, QEvent::PointerEventTag, const QInpu
/*!
\internal
*/
+QInputEvent::QInputEvent(QEvent::Type type, QEvent::SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
+ : QEvent(type, QEvent::SinglePointEventTag{}), m_dev(dev), m_modState(modifiers)
+{}
+
+/*!
+ \internal
+*/
QInputEvent::~QInputEvent()
{
}
@@ -256,6 +263,14 @@ QPointerEvent::QPointerEvent(QEvent::Type type, const QPointingDevice *dev,
{
}
+/*!
+ \internal
+*/
+QPointerEvent::QPointerEvent(QEvent::Type type, QEvent::SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers)
+{
+}
+
QPointerEvent::~QPointerEvent()
{
}
@@ -500,7 +515,7 @@ void QPointerEvent::clearPassiveGrabbers(const QEventPoint &point)
*/
QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos,
const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
- : QPointerEvent(type, dev, modifiers),
+ : QPointerEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers),
m_button(button),
m_mouseState(buttons),
m_source(Qt::MouseEventNotSynthesized),
@@ -548,7 +563,7 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *dev, const QEventPoint &point,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
- : QPointerEvent(type, dev, modifiers),
+ : QPointerEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers),
m_button(button),
m_mouseState(buttons),
m_source(source),
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 4bd7a54022..7e35a1b117 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -85,7 +85,8 @@ public:
virtual void setTimestamp(ulong timestamp) { m_timeStamp = timestamp; }
protected:
- QInputEvent(Type type, PointerEventTag, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ QInputEvent(Type type, PointerEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ QInputEvent(Type type, SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
const QInputDevice *m_dev = nullptr;
Qt::KeyboardModifiers m_modState = Qt::NoModifier;
@@ -122,6 +123,8 @@ public:
bool removePassiveGrabber(const QEventPoint &point, QObject *grabber);
protected:
+ QPointerEvent(Type type, SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+
QList<QEventPoint> m_points;
};