OSDN Git Service

libs: fix KDisplayManager::isSwitchable() when systemd is used instead of ConsoleKit
authorIvailo Monev <xakepa10@gmail.com>
Sun, 24 Apr 2022 18:03:39 +0000 (21:03 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 24 Apr 2022 18:03:39 +0000 (21:03 +0300)
for reference:
https://bugs.kde.org/show_bug.cgi?id=427777

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
libs/kworkspace/kdisplaymanager.cpp

index 0fea669..a71ba2a 100644 (file)
@@ -589,6 +589,17 @@ KDisplayManager::isSwitchable()
                 QVariant prop = SDseat.property("CanMultiSession");
                 if (prop.isValid())
                     return prop.toBool();
+                QDBusInterface systemdIface(
+                    "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager",
+                    QDBusConnection::systemBus()
+                );
+                QString systemdversion = systemdIface.property("Version").toString();
+                const int dotindex = systemdversion.indexOf(QLatin1Char('.'));
+                if (dotindex > 0) {
+                    systemdversion = systemdversion.left(dotindex);
+                }
+                // always allowed since 246 and the CanMultiSession property is hidden
+                return (systemdversion.toLongLong() >= 246);
             }
             CKSeat CKseat(currentSeat);
             if (CKseat.isValid()) {