diff options
author | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-04-30 15:18:44 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2015-05-06 07:59:19 +0000 |
commit | 1c7e3a2a33b890a19bbac57cd068aef04c134527 (patch) | |
tree | 31df95a52c9da66bf7f12b9ff46c7c3ca9c73754 /src/gui/kernel/qshapedpixmapdndwindow.cpp | |
parent | cb0705952541f3b6d83b60ea680953a43c7bfdcf (diff) | |
download | qtbase-1c7e3a2a33b890a19bbac57cd068aef04c134527.tar.gz |
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/kernel/qshapedpixmapdndwindow.cpp')
-rw-r--r-- | src/gui/kernel/qshapedpixmapdndwindow.cpp | 8 |
1 files changed, 3 insertions, 5 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 *) |