Commit 1baf39da authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

backends/drm: Improve device seat assignment handling

This fixes the drm backend adding hotplugged gpus that belong to other
seats and makes the udev helper depend on less stuff from the layer
above backends.
parent cf3fe003
Pipeline #208744 passed with stage
in 11 minutes and 19 seconds
......@@ -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")) {
......
......@@ -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 <QByteArray>
......@@ -102,23 +99,14 @@ std::vector<UdevDevice::Ptr> UdevEnumerate::find()
return {};
}
std::vector<UdevDevice::Ptr> 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));
......
......@@ -38,6 +38,7 @@ public:
QMap<QByteArray, QByteArray> properties() const;
bool isBootVga() const;
QString seat() const;
operator udev_device *() const
{
......
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