diff options
| author | vaxerski <vaxry@vaxry.net> | 2024-09-17 12:55:48 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2024-09-17 12:55:48 +0100 |
| commit | 581f6659f8541476da82ebd819a564780b3a969e (patch) | |
| tree | 632c477b33dab40f95b2c02cfc2f8de492d1ce5f /src/protocols/core/DataDevice.cpp | |
| parent | e72ae6b25fe019404df31e783ae980f80d3eaa3c (diff) | |
data-device: conform to reported source actions
fixes #7815
Diffstat (limited to 'src/protocols/core/DataDevice.cpp')
| -rw-r--r-- | src/protocols/core/DataDevice.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index eac80a83..5644f243 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -82,8 +82,19 @@ void CWLDataOfferResource::sendData() { if (!source) return; - if (resource->version() >= 3) - resource->sendSourceActions(7); + const auto SOURCEACTIONS = source->actions(); + + if (resource->version() >= 3 && SOURCEACTIONS > 0) { + resource->sendSourceActions(SOURCEACTIONS); + if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE) + resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); + else if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY) + resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY); + else { + LOGM(ERR, "Client bug? dnd source has no action move or copy. Sending move, f this."); + resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); + } + } for (auto const& m : source->mimes()) { LOGM(LOG, " | offer {:x} supports mime {}", (uintptr_t)this, m); @@ -111,7 +122,7 @@ CWLDataSourceResource::CWLDataSourceResource(SP<CWlDataSource> resource_, SP<CWL resource->setOffer([this](CWlDataSource* r, const char* mime) { mimeTypes.push_back(mime); }); resource->setSetActions([this](CWlDataSource* r, uint32_t a) { LOGM(LOG, "DataSource {:x} actions {}", (uintptr_t)this, a); - actions = (wl_data_device_manager_dnd_action)a; + supportedActions = a; }); } @@ -193,6 +204,10 @@ void CWLDataSourceResource::sendDndAction(wl_data_device_manager_dnd_action a) { resource->sendAction(a); } +uint32_t CWLDataSourceResource::actions() { + return supportedActions; +} + CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : resource(resource_) { if (!good()) return; |
