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.
This commit is contained in:
parent
cf3fe003e6
commit
1baf39daf7
3 changed files with 25 additions and 17 deletions
|
@ -215,9 +215,11 @@ bool DrmBackend::initialize()
|
|||
} else {
|
||||
const auto devices = m_udev->listGPUs();
|
||||
for (const UdevDevice::Ptr &device : devices) {
|
||||
if (device->seat() == m_session->seat()) {
|
||||
addGpu(device->devNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gpus.empty()) {
|
||||
qCWarning(KWIN_DRM) << "No suitable DRM devices have been found";
|
||||
|
@ -244,9 +246,17 @@ void DrmBackend::handleUdevEvent()
|
|||
if (!m_active) {
|
||||
continue;
|
||||
}
|
||||
if (!m_explicitGpus.isEmpty() && !m_explicitGpus.contains(device->devNode())) {
|
||||
|
||||
// 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")) {
|
||||
qCDebug(KWIN_DRM) << "New gpu found:" << device->devNode();
|
||||
|
|
|
@ -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,24 +99,15 @@ 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;
|
||||
}
|
||||
QString deviceSeat = device->property("ID_SEAT");
|
||||
if (deviceSeat.isEmpty()) {
|
||||
deviceSeat = defaultSeat;
|
||||
}
|
||||
if (deviceSeat != kwinApp()->session()->seat()) {
|
||||
continue;
|
||||
}
|
||||
if (device) {
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue