qtquick: Fix DND operation never ending
When double-clicking a title bar we're getting: Press, Release, Press and never the Release. We get the MouseDblClickEvent instead, so handle that
This commit is contained in:
@@ -165,6 +165,15 @@ bool StatePreDrag::handleMouseButtonRelease(QPoint)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StatePreDrag::handleMouseDoubleClick()
|
||||
{
|
||||
// This is only needed for QtQuick.
|
||||
// With QtQuick, when double clicking, we get: Press, Release, Press, Double-click. and never
|
||||
// receive the last Release event.
|
||||
Q_EMIT q->dragCanceled();
|
||||
return false;
|
||||
}
|
||||
|
||||
StateDragging::StateDragging(DragController *parent)
|
||||
: StateBase(parent)
|
||||
{
|
||||
@@ -296,6 +305,14 @@ bool StateDragging::handleMouseMove(QPoint globalPos)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateDragging::handleMouseDoubleClick()
|
||||
{
|
||||
// See comment in StatePreDrag::handleMouseDoubleClick().
|
||||
// Very unlikely that we're in this state though, due to manhattan length
|
||||
Q_EMIT q->dragCanceled();
|
||||
return false;
|
||||
}
|
||||
|
||||
StateDraggingWayland::StateDraggingWayland(DragController *parent)
|
||||
: StateDragging(parent)
|
||||
{
|
||||
@@ -486,6 +503,7 @@ static QMouseEvent *mouseEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonDblClick:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove:
|
||||
case QEvent::NonClientAreaMouseButtonPress:
|
||||
@@ -567,6 +585,8 @@ bool DragController::eventFilter(QObject *o, QEvent *e)
|
||||
case QEvent::NonClientAreaMouseMove:
|
||||
case QEvent::MouseMove:
|
||||
return activeState()->handleMouseMove(Qt5Qt6Compat::eventGlobalPos(me));
|
||||
case QEvent::MouseButtonDblClick:
|
||||
return activeState()->handleMouseDoubleClick();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ public:
|
||||
virtual bool handleMouseButtonPress(Draggable * /*receiver*/, QPoint /*globalPos*/, QPoint /*pos*/) { return false; }
|
||||
virtual bool handleMouseMove(QPoint /*globalPos*/) { return false; }
|
||||
virtual bool handleMouseButtonRelease(QPoint /*globalPos*/) { return false; }
|
||||
virtual bool handleMouseDoubleClick() { return false; }
|
||||
|
||||
// Only interesting for Wayland
|
||||
virtual bool handleDragEnter(QDragEnterEvent *, DropArea *) { return false; }
|
||||
@@ -138,6 +139,7 @@ public:
|
||||
void onEntry(QEvent *) override;
|
||||
bool handleMouseMove(QPoint globalPos) override;
|
||||
bool handleMouseButtonRelease(QPoint) override;
|
||||
bool handleMouseDoubleClick() override;
|
||||
};
|
||||
|
||||
// Used on all platforms except Wayland. @see StateDraggingWayland
|
||||
@@ -150,6 +152,7 @@ public:
|
||||
void onEntry(QEvent *) override;
|
||||
bool handleMouseButtonRelease(QPoint globalPos) override;
|
||||
bool handleMouseMove(QPoint globalPos) override;
|
||||
bool handleMouseDoubleClick() override;
|
||||
};
|
||||
|
||||
// Used on wayland only to use QDrag instead of setting geometry on mouse-move.
|
||||
|
||||
@@ -46,6 +46,7 @@ void TitleBarQuick::filterEvents(QObject *obj)
|
||||
bool TitleBarQuick::eventFilter(QObject *, QEvent *ev)
|
||||
{
|
||||
switch (ev->type()) {
|
||||
case QEvent::MouseButtonDblClick:
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove:
|
||||
|
||||
Reference in New Issue
Block a user