Skip to content

Commit

Permalink
data-device: send dndFinished when dnd offer is destroyed while unfin…
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Aug 28, 2024
1 parent 7dd0f76 commit 00ee1cf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/protocols/core/DataDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataS
});
}

CWLDataOfferResource::~CWLDataOfferResource() {
if (!source || !source->hasDnd() || dead)
return;

source->sendDndFinished();
}

bool CWLDataOfferResource::good() {
return resource->resource();
}
Expand Down Expand Up @@ -173,6 +180,7 @@ void CWLDataSourceResource::sendDndDropPerformed() {
if (resource->version() < 3)
return;
resource->sendDndDropPerformed();
dropped = true;
}

void CWLDataSourceResource::sendDndFinished() {
Expand Down
4 changes: 3 additions & 1 deletion src/protocols/core/DataDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CMonitor;
class CWLDataOfferResource {
public:
CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_);
~CWLDataOfferResource();

bool good();
void sendData();
Expand Down Expand Up @@ -63,14 +64,15 @@ class CWLDataSourceResource : public IDataSource {
virtual bool hasDnd();
virtual bool dndDone();
virtual void error(uint32_t code, const std::string& msg);
virtual void sendDndFinished();

void sendDndDropPerformed();
void sendDndFinished();
void sendDndAction(wl_data_device_manager_dnd_action a);

bool used = false;
bool dnd = false;
bool dndSuccess = false;
bool dropped = false;

WP<CWLDataDeviceResource> device;
WP<CWLDataSourceResource> self;
Expand Down
4 changes: 4 additions & 0 deletions src/protocols/types/DataDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ void IDataSource::markUsed() {
eDataSourceType IDataSource::type() {
return DATA_SOURCE_TYPE_WAYLAND;
}

void IDataSource::sendDndFinished() {
;
}
1 change: 1 addition & 0 deletions src/protocols/types/DataDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class IDataSource {
virtual void cancelled() = 0;
virtual bool hasDnd();
virtual bool dndDone();
virtual void sendDndFinished();
virtual bool used();
virtual void markUsed();
virtual void error(uint32_t code, const std::string& msg) = 0;
Expand Down

1 comment on commit 00ee1cf

@unbrice
Copy link

@unbrice unbrice commented on 00ee1cf Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the dropped member variable is never read.

Please sign in to comment.