platforms/drm: consider KWIN_DRM_DEVICES for hotplugged gpus

This commit is contained in:
Xaver Hugl 2021-08-17 18:11:27 +02:00
parent ff99100ec5
commit 2e0336681f
2 changed files with 7 additions and 3 deletions

View file

@ -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();

View file

@ -105,6 +105,7 @@ private:
DrmVirtualOutput *m_placeHolderOutput = nullptr;
bool m_active = false;
const QStringList m_explicitGpus;
QVector<DrmGpu*> m_gpus;
QScopedPointer<DpmsInputEventFilter> m_dpmsFilter;
};