summaryrefslogtreecommitdiffstats
path: root/src/widgets/util
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-09-01 11:13:35 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-09-01 13:27:37 +0200
commitc2aea75c220984953c53c3813717713437649999 (patch)
treee710906642169baf9213c047329d511e673bb98a /src/widgets/util
parentcf5e669a06ec1d8bd08a4db9c2849c5d7ea9fec4 (diff)
Refactor QMouseEvent to contain the position inside the window
Rename the default accessors for positions to localPos, windowPos and screenPos, to be explicit about their use. Introduce a QT_NO_INTEGER_EVENT_COORDINATES define so one can make sure to always use the float based coordinates. Fixup all Qt code to use the correct constructor that specifies all three coordinates. Change-Id: If4bb93b8d1e2eb2440260d99680c468706cfe68f Reviewed-on: http://codereview.qt.nokia.com/4058 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/widgets/util')
-rw-r--r--src/widgets/util/qflickgesture.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 07eca6c53b..c92fb94be7 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -73,7 +73,7 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
case QEvent::MouseButtonRelease:
case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(e);
- return new QMouseEvent(me->type(), QPoint(0, 0), me->globalPos(), me->button(), me->buttons(), me->modifiers());
+ return new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
}
#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMousePress:
@@ -83,7 +83,7 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
#if 1
QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
(me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
- return new QMouseEvent(met, QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
+ return new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
#else
QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
copy->setPos(me->pos());
@@ -237,7 +237,7 @@ public:
QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
- QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
+ QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
mouseButton, QApplication::mouseButtons() & ~mouseButton,
QApplication::keyboardModifiers());
sendMouseEvent(&re, RegrabMouseAfterwards);
@@ -287,7 +287,9 @@ protected:
#endif // QT_NO_GRAPHICSVIEW
if (me) {
- QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers());
+ QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()),
+ mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers());
qt_sendSpontaneousEvent(mouseTarget, &copy);
}