Skip to content

Commit

Permalink
Drag'n'drop: avoid unintended drag on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Apr 1, 2024
1 parent 9f68007 commit b8c3cdc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/util/dnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ bool allowLoadToPlayer(

// Helper function for DragAndDropHelper::mousePressed and DragAndDropHelper::mouseMoveInitiatesDrag
bool mouseMoveInitiatesDragHelper(QMouseEvent* pEvent, bool isPress) {
// Only act if left button is pressed (click or drag).
// Works around some strange Qt bug where drag is initiated instantly on hover
// without any prior click. Reproducible with WCoverArt and WTrackProperty /
// WTrackWidgetGroup (only if :hover selector is added to the skin stylesheet).
if (pEvent->button() != Qt::LeftButton) {
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const qreal x = pEvent->position().x();
const qreal y = pEvent->position().y();
Expand Down Expand Up @@ -209,9 +216,7 @@ bool DragAndDropHelper::allowDeckCloneAttempt(

// static
void DragAndDropHelper::mousePressed(QMouseEvent* pEvent) {
if (pEvent->button() == Qt::LeftButton) {
mouseMoveInitiatesDragHelper(pEvent, true);
}
mouseMoveInitiatesDragHelper(pEvent, true);
}

// static
Expand Down

0 comments on commit b8c3cdc

Please sign in to comment.