drmlease: send device done event correctly

This commit is contained in:
Xaver Hugl 2022-07-11 14:46:46 +02:00
parent 71bfbe815c
commit 919b56e9a2
3 changed files with 20 additions and 9 deletions

View file

@ -349,6 +349,9 @@ bool DrmGpu::updateOutputs()
}
}
m_leaseDevice->setDrmMaster(true);
// after (potential) lease offer changes, a done event needs to be sent
// to signal clients to handle the changes
m_leaseDevice->done();
return true;
}

View file

@ -60,6 +60,14 @@ void DrmLeaseDeviceV1Interface::setDrmMaster(bool hasDrmMaster)
d->hasDrmMaster = hasDrmMaster;
}
void DrmLeaseDeviceV1Interface::done()
{
const auto resources = d->resourceMap();
for (const auto resource : resources) {
d->send_done(resource->handle);
}
}
DrmLeaseDeviceV1InterfacePrivate::DrmLeaseDeviceV1InterfacePrivate(Display *display, DrmLeaseDeviceV1Interface *device, std::function<int()> createNonMasterFd)
: QtWaylandServer::wp_drm_lease_device_v1(*display, s_version)
, q(device)
@ -82,6 +90,7 @@ void DrmLeaseDeviceV1InterfacePrivate::remove()
for (const auto &request : qAsConst(leaseRequests)) {
request->connectors.clear();
}
q->done();
globalRemove();
}
@ -157,6 +166,7 @@ void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_bind_resource(Reso
connectorPrivate->send(connectorResource->handle);
}
}
send_done(resource->handle);
}
void DrmLeaseDeviceV1InterfacePrivate::wp_drm_lease_device_v1_destroy_global()
@ -228,12 +238,6 @@ void DrmLeaseConnectorV1InterfacePrivate::withdraw()
for (const auto &resource : resourceMap()) {
send_withdrawn(resource->handle);
}
auto devicePrivate = DrmLeaseDeviceV1InterfacePrivate::get(device);
const auto deviceMap = devicePrivate->resourceMap();
for (DrmLeaseDeviceV1InterfacePrivate::Resource *resource : deviceMap) {
devicePrivate->send_done(resource->handle);
}
}
}
@ -326,6 +330,7 @@ void DrmLeaseV1Interface::grant(int leaseFd, uint32_t lesseeId)
for (const auto &connector : qAsConst(d->connectors)) {
DrmLeaseConnectorV1InterfacePrivate::get(connector)->withdraw();
}
d->device->q->done();
}
void DrmLeaseV1Interface::deny()
@ -352,9 +357,7 @@ void DrmLeaseV1Interface::deny()
}
}
if (sent) {
for (const auto &resource : d->device->resourceMap()) {
d->device->send_done(resource->handle);
}
d->device->q->done();
}
}
d->lesseeId = 0;

View file

@ -43,6 +43,11 @@ public:
*/
void setDrmMaster(bool hasDrmMaster);
/**
* Must be called after connectors have been added or removed
*/
void done();
Q_SIGNALS:
/**
* Emitted when a lease is requested. The compositor needs to either