Skip to content

Commit

Permalink
udev: Do not filter devices by seat
Browse files Browse the repository at this point in the history
Remove the dependency with logind and let the users filter by seat.
  • Loading branch information
plfiorini committed Oct 13, 2023
1 parent ae2b3a5 commit 1191b40
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/platformsupport/udev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ liri_add_module(AuroraUdev
PUBLIC_LIBRARIES
Qt::Core
Qt::DBus
Liri::AuroraLogind
PkgConfig::Libudev
NO_CMAKE
NO_PKGCONFIG
Expand Down
9 changes: 9 additions & 0 deletions src/platformsupport/udev/udevdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ QString UdevDevice::driver() const
return QString::fromUtf8(udev_device_get_driver(d->device));
}

QString UdevDevice::seat() const
{
Q_D(const UdevDevice);
if (!d->device)
return QString();
const auto value = QString::fromUtf8(udev_device_get_property_value(d->device, "ID_SEAT"));
return value.isEmpty() ? QStringLiteral("seat0") : value;
}

QString UdevDevice::deviceNode() const
{
Q_D(const UdevDevice);
Expand Down
1 change: 1 addition & 0 deletions src/platformsupport/udev/udevdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class LIRIAURORAUDEV_EXPORT UdevDevice
QString devType() const;
QString name() const;
QString driver() const;
QString seat() const;

QString deviceNode() const;
QStringList alternateDeviceSymlinks() const;
Expand Down
9 changes: 0 additions & 9 deletions src/platformsupport/udev/udevenumerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,6 @@ QList<UdevDevice *> UdevEnumerate::scan() const
if (!dev)
continue;

// Must be on the same seat
QString seat = QString::fromUtf8(udev_device_get_property_value(dev, "ID_SEAT"));
if (seat.isEmpty())
seat = QStringLiteral("seat0");
if (seat != Logind::instance()->seat()) {
udev_device_unref(dev);
continue;
}

QString node = QString::fromUtf8(udev_device_get_devnode(dev));

if (d->types.testFlag(UdevDevice::InputDevice_Mask) && node.startsWith(QLatin1String("/dev/input/event"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,22 @@ KmsDevice *QEglFSKmsGbmIntegration::createDevice()
if (!path.isEmpty()) {
qCDebug(qLcEglfsKmsDebug) << "GBM: Using DRM device" << path << "specified in config file";
} else {
QList<Aurora::PlatformSupport::UdevDevice *> validDevices;

Aurora::PlatformSupport::UdevEnumerate enumerate(Aurora::PlatformSupport::UdevDevice::PrimaryVideoDevice | Aurora::PlatformSupport::UdevDevice::GenericVideoDevice, m_udev);
QList<Aurora::PlatformSupport::UdevDevice *> devices = enumerate.scan();
qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:";
for (auto device : qAsConst(devices))
qCDebug(qLcEglfsKmsDebug) << '\t' << device->deviceNode().toLocal8Bit().constData();
for (auto device : qAsConst(devices)) {
if (device->seat() == Logind::instance()->seat()) {
validDevices.append(device);
qCDebug(qLcEglfsKmsDebug) << '\t' << device->deviceNode().toLocal8Bit().constData();
}
}

if (Q_UNLIKELY(devices.isEmpty()))
if (Q_UNLIKELY(validDevices.isEmpty()))
qFatal("Could not find DRM device!");

path = devices.first()->deviceNode();
path = validDevices.first()->deviceNode();
qCDebug(qLcEglfsKmsDebug) << "Using" << path;
}

Expand Down

0 comments on commit 1191b40

Please sign in to comment.