summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-04-30 15:18:44 +0200
committerRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-05-06 07:59:19 +0000
commit1c7e3a2a33b890a19bbac57cd068aef04c134527 (patch)
tree31df95a52c9da66bf7f12b9ff46c7c3ca9c73754 /src/gui
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 <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow.cpp8
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow_p.h2
-rw-r--r--src/gui/kernel/qsimpledrag.cpp15
3 files changed, 16 insertions, 9 deletions
diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp
index 9d0197ef9d..8f80789fb0 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow.cpp
+++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp
@@ -86,16 +86,14 @@ void QShapedPixmapWindow::setHotspot(const QPoint &hotspot)
m_hotSpot = hotspot;
}
-void QShapedPixmapWindow::updateGeometry()
+void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
{
-#ifndef QT_NO_CURSOR
- QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size());
if (m_pixmap.isNull())
m_backingStore->resize(QSize(1,1));
else if (m_backingStore->size() != m_pixmap.size())
m_backingStore->resize(m_pixmap.size());
- setGeometry(rect);
-#endif
+
+ setGeometry(QRect(pos - m_hotSpot, m_backingStore->size()));
}
void QShapedPixmapWindow::exposeEvent(QExposeEvent *)
diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h
index ec56573195..fc311cff92 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow_p.h
+++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h
@@ -63,7 +63,7 @@ public:
void setPixmap(const QPixmap &pixmap);
void setHotspot(const QPoint &hotspot);
- void updateGeometry();
+ void updateGeometry(const QPoint &pos);
protected:
void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE;
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->setPixmap(m_drag->pixmap());
m_drag_icon_window->setHotspot(m_drag->hotSpot());
- 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);
+#endif
+
m_drag_icon_window->setVisible(true);
enableEventFilter();
@@ -218,10 +227,10 @@ void QBasicDrag::cancel()
m_drag_icon_window->setVisible(false);
}
-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 *)