path: root/src/gui/kernel/qsimpledrag.cpp
diff options
authorRichard Moe Gustavsen <>2015-04-30 15:18:44 +0200
committerRichard Moe Gustavsen <>2015-05-06 07:59:19 +0000
commit1c7e3a2a33b890a19bbac57cd068aef04c134527 (patch)
tree31df95a52c9da66bf7f12b9ff46c7c3ca9c73754 /src/gui/kernel/qsimpledrag.cpp
parentcb0705952541f3b6d83b60ea680953a43c7bfdcf (diff)
QShapedPixmapWindow: ensure we set a valid geometry
On touch platforms, QCursor::pos() will only be 'valid' when a touch event has (at least once) been translated to a mouse event. Currently this never happens in QtQuick since QtQuick always accepts all touch events and performs its own translations. So rather than setting the geometry of QShapedPixmapWindow from QCursor directly, we instead base it on mouse events. This will ensure that we never try to set the geometry of the window to an 'invalid' value, which can cause a crash on platforms like iOS. Note that we currenly miss an API in Qt to get the current touch points. When that is in place, we can also set a correct start position for the window before the first mouse move event arrives. Task-number: QTBUG-45877 Change-Id: I320598e87d43f6e9e087c204a69b95465128f468 Reviewed-by: Friedemann Kleint <>
Diffstat (limited to 'src/gui/kernel/qsimpledrag.cpp')
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 090e88c118..b850f53014 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -201,7 +201,16 @@ void QBasicDrag::startDrag()
- m_drag_icon_window->updateGeometry();
+#ifndef QT_NO_CURSOR
+ QPoint pos = QCursor::pos();
+ if (pos.x() == int(qInf())) {
+ // ### fixme: no mouse pos registered. Get pos from touch...
+ pos = QPoint();
+ }
+ m_drag_icon_window->updateGeometry(pos);
@@ -218,10 +227,10 @@ void QBasicDrag::cancel()
-void QBasicDrag::move(const QMouseEvent *)
+void QBasicDrag::move(const QMouseEvent *e)
if (m_drag)
- m_drag_icon_window->updateGeometry();
+ m_drag_icon_window->updateGeometry(e->globalPos());
void QBasicDrag::drop(const QMouseEvent *)