Fix DnD when using QSimpleDrag.
qApp->topLevelAt() returns the QShapedPixmapWindow that the DnD operation created, but what we want is the QWidgetWindow. QWidgetWindow has the code to handle QDragMove events. In Qt4, QShapedPixmapWidget had a parent, so was never returned by qApp->topLevelWidgets(). In Qt5 we must filter it out. Bug is visible in the QNX plugin, which is the only user of QSimpleDrag. Change-Id: I920da86f3a1a92ce8e087f5948292fa4c68d4d81 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
25ae390461
commit
742f0c6e0b
@ -52,6 +52,7 @@ QT_BEGIN_HEADER
|
|||||||
|
|
||||||
class QShapedPixmapWindow : public QWindow
|
class QShapedPixmapWindow : public QWindow
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QShapedPixmapWindow();
|
QShapedPixmapWindow();
|
||||||
|
|
||||||
|
@ -68,6 +68,17 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
#ifndef QT_NO_DRAGANDDROP
|
#ifndef QT_NO_DRAGANDDROP
|
||||||
|
|
||||||
|
static QWindow* topLevelAt(const QPoint &pos)
|
||||||
|
{
|
||||||
|
QWindowList list = QGuiApplication::topLevelWindows();
|
||||||
|
for (int i = list.count()-1; i >= 0; --i) {
|
||||||
|
QWindow *w = list.at(i);
|
||||||
|
if (w->isVisible() && w->geometry().contains(pos) && !qobject_cast<QShapedPixmapWindow*>(w))
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QBasicDrag
|
\class QBasicDrag
|
||||||
\brief QBasicDrag is a base class for implementing platform drag and drop.
|
\brief QBasicDrag is a base class for implementing platform drag and drop.
|
||||||
@ -298,7 +309,7 @@ QMimeData *QSimpleDrag::platformDropData()
|
|||||||
void QSimpleDrag::startDrag()
|
void QSimpleDrag::startDrag()
|
||||||
{
|
{
|
||||||
QBasicDrag::startDrag();
|
QBasicDrag::startDrag();
|
||||||
m_current_window = QGuiApplication::topLevelAt(QCursor::pos());
|
m_current_window = topLevelAt(QCursor::pos());
|
||||||
if (m_current_window) {
|
if (m_current_window) {
|
||||||
QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions());
|
QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions());
|
||||||
setCanDrop(response.isAccepted());
|
setCanDrop(response.isAccepted());
|
||||||
@ -321,7 +332,7 @@ void QSimpleDrag::cancel()
|
|||||||
void QSimpleDrag::move(const QMouseEvent *me)
|
void QSimpleDrag::move(const QMouseEvent *me)
|
||||||
{
|
{
|
||||||
QBasicDrag::move(me);
|
QBasicDrag::move(me);
|
||||||
QWindow *window = QGuiApplication::topLevelAt(me->globalPos());
|
QWindow *window = topLevelAt(me->globalPos());
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -336,7 +347,7 @@ void QSimpleDrag::move(const QMouseEvent *me)
|
|||||||
void QSimpleDrag::drop(const QMouseEvent *me)
|
void QSimpleDrag::drop(const QMouseEvent *me)
|
||||||
{
|
{
|
||||||
QBasicDrag::drop(me);
|
QBasicDrag::drop(me);
|
||||||
QWindow *window = QGuiApplication::topLevelAt(me->globalPos());
|
QWindow *window = topLevelAt(me->globalPos());
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user