Commit 7c09b463 authored by Marco Martin's avatar Marco Martin
Browse files

Add a methood to fore cancel any drag in progress

This is needed to cancel drags by pressing Escape which is
resposibility of the compositor

CCBUG:405267
parent 7ed6fae8
Pipeline #144366 passed with stage
in 4 minutes and 36 seconds
......@@ -195,6 +195,14 @@ KWaylandServer::AbstractDropHandler *SeatInterface::dropHandlerForSurface(Surfac
return list.first();
}
void SeatInterface::cancelDrag()
{
if (d->drag.mode != SeatInterfacePrivate::Drag::Mode::None) {
// cancel the drag, don't drop. serial does not matter
d->cancelDrag();
}
}
void SeatInterfacePrivate::registerDataControlDevice(DataControlDeviceV1Interface *dataDevice)
{
Q_ASSERT(dataDevice->seat() == q);
......@@ -268,16 +276,16 @@ void SeatInterfacePrivate::registerPrimarySelectionDevice(PrimarySelectionDevice
}
}
void SeatInterfacePrivate::cancelDrag(quint32 serial)
void SeatInterfacePrivate::cancelDrag()
{
if (drag.target) {
drag.target->updateDragTarget(nullptr, serial);
drag.target->updateDragTarget(nullptr, 0);
drag.target = nullptr;
}
endDrag(serial);
endDrag();
}
void SeatInterfacePrivate::endDrag(quint32 serial)
void SeatInterfacePrivate::endDrag()
{
QObject::disconnect(drag.dragSourceDestroyConnection);
......@@ -295,7 +303,7 @@ void SeatInterfacePrivate::endDrag(quint32 serial)
}
if (dragTargetDevice) {
dragTargetDevice->updateDragTarget(nullptr, serial);
dragTargetDevice->updateDragTarget(nullptr, 0);
}
drag = Drag();
......@@ -708,7 +716,7 @@ void SeatInterface::notifyPointerButton(quint32 button, PointerButtonState state
// not our drag button - ignore
return;
}
d->endDrag(serial);
d->endDrag();
return;
}
}
......@@ -972,7 +980,7 @@ void SeatInterface::notifyTouchCancel()
if (d->drag.mode == SeatInterfacePrivate::Drag::Mode::Touch) {
// cancel the drag, don't drop. serial does not matter
d->cancelDrag(0);
d->cancelDrag();
}
d->globalTouch.ids.clear();
}
......@@ -1116,7 +1124,7 @@ void SeatInterface::notifyTouchUp(qint32 id)
const qint32 serial = d->display->nextSerial();
if (d->drag.mode == SeatInterfacePrivate::Drag::Mode::Touch && d->drag.dragImplicitGrabSerial == d->globalTouch.ids.value(id)) {
// the implicitly grabbing touch point has been upped
d->endDrag(serial);
d->endDrag();
}
d->touch->sendUp(id, serial);
......@@ -1336,7 +1344,7 @@ void SeatInterface::startDrag(AbstractDataSource *dragSource, SurfaceInterface *
d->drag.source = dragSource;
if (dragSource) {
d->drag.dragSourceDestroyConnection = QObject::connect(dragSource, &AbstractDataSource::aboutToBeDestroyed, this, [this] {
d->cancelDrag(d->display->nextSerial());
d->cancelDrag();
});
}
d->drag.dragIcon = dragIcon;
......
......@@ -229,6 +229,11 @@ public:
AbstractDropHandler *dropHandlerForSurface(SurfaceInterface *surface) const;
/**
* If there is a current drag in progress, force it to cancel
*/
void cancelDrag();
/**
* @name Pointer related methods
*/
......
......@@ -41,8 +41,8 @@ public:
void registerPrimarySelectionDevice(PrimarySelectionDeviceV1Interface *primarySelectionDevice);
void registerDataDevice(DataDeviceInterface *dataDevice);
void registerDataControlDevice(DataControlDeviceV1Interface *dataDevice);
void endDrag(quint32 serial);
void cancelDrag(quint32 serial);
void endDrag();
void cancelDrag();
SeatInterface *q;
QPointer<Display> display;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment