Move drag icon relative the cursor hotspot position

Instead of placing the drag icons top-left corner at the cursors
hotspot the drag icon is moved so it will be placed correct relative
the cursor hotspot. This will makes the drag feeling more realistic.

Change-Id: I8d60ae1b7788accb9034575983417abae4c58c1a
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Erik Larsson 2016-04-17 20:34:21 +02:00
parent f1bf4fc2c6
commit c477d954ae
3 changed files with 7 additions and 0 deletions

View File

@ -74,6 +74,7 @@ void QWaylandDrag::startDrag()
QBasicDrag::startDrag();
QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon);
icon->addAttachOffset(-drag()->hotSpot());
}
void QWaylandDrag::cancel()

View File

@ -905,6 +905,11 @@ void QWaylandWindow::requestUpdate()
mUpdateRequested = true;
}
void QWaylandWindow::addAttachOffset(const QPoint point)
{
mOffset += point;
}
}
QT_END_NAMESPACE

View File

@ -197,6 +197,7 @@ public:
bool setKeyboardGrabEnabled(bool) Q_DECL_OVERRIDE { return false; }
void propagateSizeHints() Q_DECL_OVERRIDE { }
void addAttachOffset(const QPoint point);
void requestUpdate() Q_DECL_OVERRIDE;