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,7 +215,9 @@ bool DrmBackend::initialize()
|
||||||
} else {
|
} else {
|
||||||
const auto devices = m_udev->listGPUs();
|
const auto devices = m_udev->listGPUs();
|
||||||
for (const UdevDevice::Ptr &device : devices) {
|
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) {
|
if (!m_active) {
|
||||||
continue;
|
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")) {
|
if (device->action() == QStringLiteral("add")) {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
#include "main.h"
|
|
||||||
#include "platform.h"
|
|
||||||
#include "session.h"
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
// Qt
|
// Qt
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
@ -102,23 +99,14 @@ std::vector<UdevDevice::Ptr> UdevEnumerate::find()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
std::vector<UdevDevice::Ptr> vect;
|
std::vector<UdevDevice::Ptr> vect;
|
||||||
QString defaultSeat = QStringLiteral("seat0");
|
|
||||||
udev_list_entry *it = udev_enumerate_get_list_entry(m_enumerate.data());
|
udev_list_entry *it = udev_enumerate_get_list_entry(m_enumerate.data());
|
||||||
while (it) {
|
while (it) {
|
||||||
auto current = it;
|
auto current = it;
|
||||||
it = udev_list_entry_get_next(it);
|
it = udev_list_entry_get_next(it);
|
||||||
auto device = m_udev->deviceFromSyspath(udev_list_entry_get_name(current));
|
auto device = m_udev->deviceFromSyspath(udev_list_entry_get_name(current));
|
||||||
if (!device) {
|
if (device) {
|
||||||
continue;
|
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;
|
return vect;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +218,15 @@ bool UdevDevice::isBootVga() const
|
||||||
return systAttrValue && qstrcmp(systAttrValue, "1") == 0;
|
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
|
QString UdevDevice::action() const
|
||||||
{
|
{
|
||||||
return QString::fromLocal8Bit(udev_device_get_action(m_device));
|
return QString::fromLocal8Bit(udev_device_get_action(m_device));
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
|
|
||||||
QMap<QByteArray, QByteArray> properties() const;
|
QMap<QByteArray, QByteArray> properties() const;
|
||||||
bool isBootVga() const;
|
bool isBootVga() const;
|
||||||
|
QString seat() const;
|
||||||
|
|
||||||
operator udev_device *() const
|
operator udev_device *() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue