diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index f54d8b1fb3..86c6569e27 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -215,7 +215,9 @@ bool DrmBackend::initialize() } else { const auto devices = m_udev->listGPUs(); for (const UdevDevice::Ptr &device : devices) { - addGpu(device->devNode()); + if (device->seat() == m_session->seat()) { + addGpu(device->devNode()); + } } } @@ -244,8 +246,16 @@ void DrmBackend::handleUdevEvent() if (!m_active) { continue; } - if (!m_explicitGpus.isEmpty() && !m_explicitGpus.contains(device->devNode())) { - continue; + + // Ignore the device seat if the KWIN_DRM_DEVICES envvar is set. + if (!m_explicitGpus.isEmpty()) { + if (!m_explicitGpus.contains(device->devNode())) { + continue; + } + } else { + if (device->seat() != m_session->seat()) { + continue; + } } if (device->action() == QStringLiteral("add")) { diff --git a/src/utils/udev.cpp b/src/utils/udev.cpp index 02dec3960e..398fed7d9c 100644 --- a/src/utils/udev.cpp +++ b/src/utils/udev.cpp @@ -7,9 +7,6 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "udev.h" -#include "main.h" -#include "platform.h" -#include "session.h" #include "utils/common.h" // Qt #include @@ -102,23 +99,14 @@ std::vector UdevEnumerate::find() return {}; } std::vector vect; - QString defaultSeat = QStringLiteral("seat0"); udev_list_entry *it = udev_enumerate_get_list_entry(m_enumerate.data()); while (it) { auto current = it; it = udev_list_entry_get_next(it); auto device = m_udev->deviceFromSyspath(udev_list_entry_get_name(current)); - if (!device) { - continue; + if (device) { + vect.push_back(std::move(device)); } - QString deviceSeat = device->property("ID_SEAT"); - if (deviceSeat.isEmpty()) { - deviceSeat = defaultSeat; - } - if (deviceSeat != kwinApp()->session()->seat()) { - continue; - } - vect.push_back(std::move(device)); } return vect; } @@ -230,6 +218,15 @@ bool UdevDevice::isBootVga() const return systAttrValue && qstrcmp(systAttrValue, "1") == 0; } +QString UdevDevice::seat() const +{ + QString deviceSeat = udev_device_get_property_value(m_device, "ID_SEAT"); + if (deviceSeat.isEmpty()) { + deviceSeat = QStringLiteral("seat0"); + } + return deviceSeat; +} + QString UdevDevice::action() const { return QString::fromLocal8Bit(udev_device_get_action(m_device)); diff --git a/src/utils/udev.h b/src/utils/udev.h index 96a0c47e9b..9a5538b54f 100644 --- a/src/utils/udev.h +++ b/src/utils/udev.h @@ -38,6 +38,7 @@ public: QMap properties() const; bool isBootVga() const; + QString seat() const; operator udev_device *() const {