summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-07-09 08:28:42 +0200
committerMichal Klocek <michal.klocek@theqtcompany.com>2015-07-13 14:31:23 +0000
commitc93d0f85b2b1fbd623a938c0d1a0d7c6ea0d784f (patch)
tree8ff6163c850db156c84658ff5086b9b3bba79614
parent0891ea11e0000289354ab62f8c4c3d21e008823a (diff)
Do not rely on synthesized MouseReleseEvent when tracking mouse point
A map pan is based on synthesized events due to the fact that rest of qt (qtcontrols , mouse area etc) depend on it in case of touch handling. However when there are two touch points on the screen pinch handling is activated. After accepting the touch event, mouse synthesized events are no longer generated for the first touch point, what's more as a result we might not get even mouseUngrabEvent nor mouseReleaseEvent. This breaks internal tracking of mouse position. This workaround resets mouse tracking point in case of getting touchUngrabEvent. Remove dummy extra MouseArea from places example. TODO: fix broken mouse area state in pinch unit tests Task-number: QTBUG-46388 Change-Id: I5588fbd4dbf0c5d25c44f994292c1aae7b3d70d4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r--examples/location/places/items/MapComponent.qml5
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp5
-rw-r--r--src/imports/location/qquickgeomapgesturearea.cpp25
-rw-r--r--tests/auto/declarative_ui/tst_map_pinch.qml1
4 files changed, 23 insertions, 13 deletions
diff --git a/examples/location/places/items/MapComponent.qml b/examples/location/places/items/MapComponent.qml
index ccf1415d..de4e04a7 100644
--- a/examples/location/places/items/MapComponent.qml
+++ b/examples/location/places/items/MapComponent.qml
@@ -211,9 +211,4 @@ Map {
map.zoomLevel = value
}
}
-
- MouseArea {
- //workaround for QTBUG-46388
- anchors.fill: parent
- }
}
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index ccff4fd1..cf492977 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -942,9 +942,10 @@ void QDeclarativeGeoMap::touchEvent(QTouchEvent *event)
event->type() == QEvent::TouchCancel) {
ungrabTouchPoints();
}
+ } else {
+ //ignore event so sythesized event is generated;
+ QQuickItem::touchEvent(event);
}
- //this will always ignore event so sythesized event is generated;
- QQuickItem::touchEvent(event);
}
/*!
diff --git a/src/imports/location/qquickgeomapgesturearea.cpp b/src/imports/location/qquickgeomapgesturearea.cpp
index c3536e11..8c4eadda 100644
--- a/src/imports/location/qquickgeomapgesturearea.cpp
+++ b/src/imports/location/qquickgeomapgesturearea.cpp
@@ -620,8 +620,12 @@ void QQuickGeoMapGestureArea::handleMouseMoveEvent(QMouseEvent *event)
*/
void QQuickGeoMapGestureArea::handleMouseReleaseEvent(QMouseEvent *event)
{
- m_mousePoint.reset(createTouchPointFromMouseEvent(event, Qt::TouchPointReleased));
- if (m_touchPoints.isEmpty()) update();
+ if (!m_mousePoint.isNull()) {
+ //this looks super ugly , however is required in case we do not get synthesized MouseReleaseEvent
+ //and we reset the point already in handleTouchUngrabEvent
+ m_mousePoint.reset(createTouchPointFromMouseEvent(event, Qt::TouchPointReleased));
+ if (m_touchPoints.isEmpty()) update();
+ }
event->accept();
}
@@ -630,9 +634,13 @@ void QQuickGeoMapGestureArea::handleMouseReleaseEvent(QMouseEvent *event)
*/
void QQuickGeoMapGestureArea::handleMouseUngrabEvent()
{
- m_mousePoint.reset();
- if (m_touchPoints.isEmpty())
+
+ if (m_touchPoints.isEmpty() && !m_mousePoint.isNull()) {
+ m_mousePoint.reset();
update();
+ } else {
+ m_mousePoint.reset();
+ }
}
/*!
@@ -640,8 +648,11 @@ void QQuickGeoMapGestureArea::handleMouseUngrabEvent()
*/
void QQuickGeoMapGestureArea::handleTouchUngrabEvent()
{
- m_touchPoints.clear();
- update();
+ m_touchPoints.clear();
+ //this is needed since in some cases mouse release is not delivered
+ //(second touch point brakes mouse synthesized events)
+ m_mousePoint.reset();
+ update();
}
/*!
@@ -654,6 +665,8 @@ void QQuickGeoMapGestureArea::handleTouchEvent(QTouchEvent *event)
m_touchPoints << event->touchPoints().at(i);
if (event->touchPoints().count() >= 2)
event->accept();
+ else
+ event->ignore();
update();
}
diff --git a/tests/auto/declarative_ui/tst_map_pinch.qml b/tests/auto/declarative_ui/tst_map_pinch.qml
index bdf88e29..f4e57faa 100644
--- a/tests/auto/declarative_ui/tst_map_pinch.qml
+++ b/tests/auto/declarative_ui/tst_map_pinch.qml
@@ -118,6 +118,7 @@ Item {
map.center = coordinate
map.minimumZoomLevel = 0
map.maximumZoomLevel = 20
+ mouseRelease(mouseAreaTop,0,0) //Fixme: mouse area state gets broken across the tests
mouseAreaBottom.visible = false
mouseAreaTop.visible = false
pinchGenerator.clear()