Commit fe003909 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

platforms/drm: Don't search for gpus on add udev event

If a gpu is added, don't search for it pointlessly in m_gpus.
parent a2ed8cb9
......@@ -236,13 +236,7 @@ void DrmBackend::handleUdevEvent()
if (!session()->isActive()) {
continue;
}
DrmGpu *drmGpu = nullptr;
for (const auto &gpu : qAsConst(m_gpus)) {
if (gpu->drmId() == device->sysNum()) {
drmGpu = gpu;
break;
}
}
if (device->action() == QStringLiteral("add")) {
if (m_gpus.isEmpty() || !primaryGpu()->useEglStreams()) {
if (const auto &gpu = addGpu(std::move(device))) {
......@@ -251,24 +245,28 @@ void DrmBackend::handleUdevEvent()
emit gpuAdded(gpu);
}
}
} else if (drmGpu) {
if (device->action() == QStringLiteral("change")) {
qCDebug(KWIN_DRM) << "Received hot plug event for monitored drm device";
updateOutputs();
updateCursor();
} else if (device->action() == QStringLiteral("remove")) {
if (primaryGpu() == drmGpu) {
} else if (device->action() == QStringLiteral("remove")) {
DrmGpu *gpu = findGpu(device->sysNum());
if (gpu) {
if (primaryGpu() == gpu) {
qCCritical(KWIN_DRM) << "Primary gpu has been removed! Quitting...";
kwinApp()->quit();
return;
} else {
emit gpuRemoved(drmGpu);
m_gpus.removeOne(drmGpu);
delete drmGpu;
emit gpuRemoved(gpu);
m_gpus.removeOne(gpu);
delete gpu;
updateOutputs();
updateCursor();
}
}
} else if (device->action() == QStringLiteral("change")) {
DrmGpu *gpu = findGpu(device->sysNum());
if (gpu) {
qCDebug(KWIN_DRM) << "Received hot plug event for monitored drm device";
updateOutputs();
updateCursor();
}
}
}
}
......@@ -675,4 +673,14 @@ DrmGpu *DrmBackend::primaryGpu() const
return m_gpus.isEmpty() ? nullptr : m_gpus[0];
}
DrmGpu *DrmBackend::findGpu(int sysNum) const
{
for (DrmGpu *gpu : qAsConst(m_gpus)) {
if (gpu->drmId() == sysNum) {
return gpu;
}
}
return nullptr;
}
}
......@@ -64,6 +64,7 @@ public:
QString supportInformation() const override;
DrmGpu *primaryGpu() const;
DrmGpu *findGpu(int sysNum) const;
public Q_SLOTS:
void turnOutputsOn();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment