mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 16:05:58 +01:00
parent
fb82f6bcd7
commit
46ef6653be
2 changed files with 27 additions and 2 deletions
|
@ -13,13 +13,17 @@ CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataS
|
||||||
return;
|
return;
|
||||||
|
|
||||||
resource->setDestroy([this](CWlDataOffer* r) {
|
resource->setDestroy([this](CWlDataOffer* r) {
|
||||||
if (!dead)
|
if (!dead && (recvd || accepted))
|
||||||
PROTO::data->completeDrag();
|
PROTO::data->completeDrag();
|
||||||
|
else
|
||||||
|
PROTO::data->abortDrag();
|
||||||
PROTO::data->destroyResource(this);
|
PROTO::data->destroyResource(this);
|
||||||
});
|
});
|
||||||
resource->setOnDestroy([this](CWlDataOffer* r) {
|
resource->setOnDestroy([this](CWlDataOffer* r) {
|
||||||
if (!dead)
|
if (!dead && (recvd || accepted))
|
||||||
PROTO::data->completeDrag();
|
PROTO::data->completeDrag();
|
||||||
|
else
|
||||||
|
PROTO::data->abortDrag();
|
||||||
PROTO::data->destroyResource(this);
|
PROTO::data->destroyResource(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -592,6 +596,11 @@ void CWLDataDeviceProtocol::dropDrag() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wasDragSuccessful()) {
|
||||||
|
abortDrag();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dnd.currentSource->sendDndDropPerformed();
|
dnd.currentSource->sendDndDropPerformed();
|
||||||
dnd.focusedDevice->sendDrop();
|
dnd.focusedDevice->sendDrop();
|
||||||
dnd.focusedDevice->sendLeave();
|
dnd.focusedDevice->sendLeave();
|
||||||
|
@ -603,6 +612,21 @@ void CWLDataDeviceProtocol::dropDrag() {
|
||||||
dnd.overriddenCursor = false;
|
dnd.overriddenCursor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CWLDataDeviceProtocol::wasDragSuccessful() {
|
||||||
|
if (!dnd.focusedDevice || !dnd.currentSource)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (auto& o : m_vOffers) {
|
||||||
|
if (o->dead || !o->source || !o->source->hasDnd())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (o->recvd || o->accepted)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CWLDataDeviceProtocol::completeDrag() {
|
void CWLDataDeviceProtocol::completeDrag() {
|
||||||
resetDndState();
|
resetDndState();
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
|
||||||
void dropDrag();
|
void dropDrag();
|
||||||
void completeDrag();
|
void completeDrag();
|
||||||
void resetDndState();
|
void resetDndState();
|
||||||
|
bool wasDragSuccessful();
|
||||||
|
|
||||||
//
|
//
|
||||||
SP<CWLDataDeviceResource> dataDeviceForClient(wl_client*);
|
SP<CWLDataDeviceResource> dataDeviceForClient(wl_client*);
|
||||||
|
|
Loading…
Reference in a new issue