tests: Only track one data offer during a drag

A drag consists of one data source which in turn will be represented by
one data device sent to each client.

We don't need to manage a list

Change-Id: Icd2aba3ced1d8254d15400b0b687888b0872cc35
Pick-to: 6.7
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
David Edmundson 2023-03-02 16:05:05 +00:00
parent 96b9b72016
commit a55d86be87
2 changed files with 5 additions and 8 deletions

View File

@ -51,7 +51,7 @@ DataOffer *DataDevice::sendDataOffer(wl_client *client, const QStringList &mimeT
{ {
Q_ASSERT(client); Q_ASSERT(client);
auto *offer = new DataOffer(this, client, m_manager->m_version); auto *offer = new DataOffer(this, client, m_manager->m_version);
m_offers << offer; m_offer = offer;
for (auto *resource : resourceMap().values(client)) for (auto *resource : resourceMap().values(client))
wl_data_device::send_data_offer(resource->handle, offer->resource()->handle); wl_data_device::send_data_offer(resource->handle, offer->resource()->handle);
for (const auto &mimeType : mimeTypes) for (const auto &mimeType : mimeTypes)
@ -71,8 +71,8 @@ void DataDevice::sendEnter(Surface *surface, const QPoint &position)
{ {
uint serial = m_manager->m_compositor->nextSerial(); uint serial = m_manager->m_compositor->nextSerial();
Resource *resource = resourceMap().value(surface->resource()->client()); Resource *resource = resourceMap().value(surface->resource()->client());
for (DataOffer *offer: m_offers) if (m_offer)
wl_data_device::send_enter(resource->handle, serial, surface->resource()->handle, position.x(), position.y(), offer->resource()->handle); wl_data_device::send_enter(resource->handle, serial, surface->resource()->handle, position.x(), position.y(), m_offer->resource()->handle);
} }
void DataDevice::sendMotion(Surface *surface, const QPoint &position) void DataDevice::sendMotion(Surface *surface, const QPoint &position)
@ -108,10 +108,7 @@ void DataOffer::data_offer_receive(Resource *resource, const QString &mime_type,
void DataOffer::data_offer_destroy(QtWaylandServer::wl_data_offer::Resource *resource) void DataOffer::data_offer_destroy(QtWaylandServer::wl_data_offer::Resource *resource)
{ {
bool removed = m_dataDevice->m_sentSelectionOffers.removeOne(this); m_dataDevice->m_sentSelectionOffers.removeOne(this);
if (!removed)
removed = m_dataDevice->m_offers.removeOne(this);
QVERIFY(removed);
wl_resource_destroy(resource->handle); wl_resource_destroy(resource->handle);
} }

View File

@ -63,7 +63,7 @@ public:
DataDeviceManager *m_manager = nullptr; DataDeviceManager *m_manager = nullptr;
Seat *m_seat = nullptr; Seat *m_seat = nullptr;
QList<DataOffer *> m_sentSelectionOffers; QList<DataOffer *> m_sentSelectionOffers;
QList<DataOffer *> m_offers; QPointer<DataOffer> m_offer;
signals: signals:
void dragStarted(); void dragStarted();