data-device: send dndFinished when dnd offer is destroyed while unfinished

fixes #7496

see 711c5bb43f

see https://bugs.kde.org/show_bug.cgi\?id\=482142
This commit is contained in:
Vaxry 2024-08-28 13:45:06 +02:00
parent 7dd0f76e5a
commit 00ee1cf98e
4 changed files with 16 additions and 1 deletions

View file

@ -67,6 +67,13 @@ CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataS
}); });
} }
CWLDataOfferResource::~CWLDataOfferResource() {
if (!source || !source->hasDnd() || dead)
return;
source->sendDndFinished();
}
bool CWLDataOfferResource::good() { bool CWLDataOfferResource::good() {
return resource->resource(); return resource->resource();
} }
@ -173,6 +180,7 @@ void CWLDataSourceResource::sendDndDropPerformed() {
if (resource->version() < 3) if (resource->version() < 3)
return; return;
resource->sendDndDropPerformed(); resource->sendDndDropPerformed();
dropped = true;
} }
void CWLDataSourceResource::sendDndFinished() { void CWLDataSourceResource::sendDndFinished() {

View file

@ -29,6 +29,7 @@ class CMonitor;
class CWLDataOfferResource { class CWLDataOfferResource {
public: public:
CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_); CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_);
~CWLDataOfferResource();
bool good(); bool good();
void sendData(); void sendData();
@ -63,14 +64,15 @@ class CWLDataSourceResource : public IDataSource {
virtual bool hasDnd(); virtual bool hasDnd();
virtual bool dndDone(); virtual bool dndDone();
virtual void error(uint32_t code, const std::string& msg); virtual void error(uint32_t code, const std::string& msg);
virtual void sendDndFinished();
void sendDndDropPerformed(); void sendDndDropPerformed();
void sendDndFinished();
void sendDndAction(wl_data_device_manager_dnd_action a); void sendDndAction(wl_data_device_manager_dnd_action a);
bool used = false; bool used = false;
bool dnd = false; bool dnd = false;
bool dndSuccess = false; bool dndSuccess = false;
bool dropped = false;
WP<CWLDataDeviceResource> device; WP<CWLDataDeviceResource> device;
WP<CWLDataSourceResource> self; WP<CWLDataSourceResource> self;

View file

@ -19,3 +19,7 @@ void IDataSource::markUsed() {
eDataSourceType IDataSource::type() { eDataSourceType IDataSource::type() {
return DATA_SOURCE_TYPE_WAYLAND; return DATA_SOURCE_TYPE_WAYLAND;
} }
void IDataSource::sendDndFinished() {
;
}

View file

@ -21,6 +21,7 @@ class IDataSource {
virtual void cancelled() = 0; virtual void cancelled() = 0;
virtual bool hasDnd(); virtual bool hasDnd();
virtual bool dndDone(); virtual bool dndDone();
virtual void sendDndFinished();
virtual bool used(); virtual bool used();
virtual void markUsed(); virtual void markUsed();
virtual void error(uint32_t code, const std::string& msg) = 0; virtual void error(uint32_t code, const std::string& msg) = 0;