From 2e0336681fe7180401ebc7ad384bde809f3466b8 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 17 Aug 2021 18:11:27 +0200 Subject: [PATCH] platforms/drm: consider KWIN_DRM_DEVICES for hotplugged gpus --- src/plugins/platforms/drm/drm_backend.cpp | 9 ++++++--- src/plugins/platforms/drm/drm_backend.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/drm/drm_backend.cpp b/src/plugins/platforms/drm/drm_backend.cpp index 669880447d..31c6b0b066 100644 --- a/src/plugins/platforms/drm/drm_backend.cpp +++ b/src/plugins/platforms/drm/drm_backend.cpp @@ -66,6 +66,7 @@ DrmBackend::DrmBackend(QObject *parent) , m_udev(new Udev) , m_udevMonitor(m_udev->monitor()) , m_session(Session::create(this)) + , m_explicitGpus(qEnvironmentVariable("KWIN_DRM_DEVICES").split(':', Qt::SkipEmptyParts)) , m_dpmsFilter() { setSupportsGammaControl(true); @@ -195,9 +196,8 @@ bool DrmBackend::initialize() connect(session(), &Session::activeChanged, this, &DrmBackend::activate); connect(session(), &Session::awoke, this, &DrmBackend::turnOutputsOn); - const QStringList explicitGpus = qEnvironmentVariable("KWIN_DRM_DEVICES").split(':', Qt::SkipEmptyParts); - if (!explicitGpus.isEmpty()) { - for (const QString &fileName : explicitGpus) { + if (!m_explicitGpus.isEmpty()) { + for (const QString &fileName : m_explicitGpus) { addGpu(fileName); } } else { @@ -254,6 +254,9 @@ void DrmBackend::handleUdevEvent() } if (device->action() == QStringLiteral("add")) { + if (!m_explicitGpus.isEmpty() && !m_explicitGpus.contains(device->devNode())) { + continue; + } qCDebug(KWIN_DRM) << "New gpu found:" << device->devNode(); if (addGpu(device->devNode())) { updateOutputs(); diff --git a/src/plugins/platforms/drm/drm_backend.h b/src/plugins/platforms/drm/drm_backend.h index f26c7bf791..2b844cbf53 100644 --- a/src/plugins/platforms/drm/drm_backend.h +++ b/src/plugins/platforms/drm/drm_backend.h @@ -105,6 +105,7 @@ private: DrmVirtualOutput *m_placeHolderOutput = nullptr; bool m_active = false; + const QStringList m_explicitGpus; QVector m_gpus; QScopedPointer m_dpmsFilter; };