wayland: Port logind session from GetSessionByPID

It's needed to make kwin_wayland properly systemd managed. A service
launched using systemctl --user is per user, not session.

As a consequence, user services run outside the session. Applications
that deal with user session need some quirks to work with systemd boot.

Unfortunately, GetSessionByPID() doesn't work well with systemd boot,
see bug 433364. GetSession(auto) is shown to work better.
This commit is contained in:
Vlad Zahorodnii 2021-05-13 17:00:24 +03:00
parent f4715b9ac5
commit c1969afa10

View file

@ -61,19 +61,11 @@ static const QString s_managerPath = QStringLiteral("/org/freedesktop/login1");
static QString findProcessSessionPath()
{
const QString sessionId = qEnvironmentVariable("XDG_SESSION_ID");
QDBusMessage message;
if (sessionId.isEmpty()) {
message = QDBusMessage::createMethodCall(s_serviceName, s_managerPath,
s_managerInterface,
QStringLiteral("GetSessionByPID"));
message.setArguments({uint32_t(QCoreApplication::applicationPid())});
} else {
message = QDBusMessage::createMethodCall(s_serviceName, s_managerPath,
s_managerInterface,
QStringLiteral("GetSession"));
message.setArguments({sessionId});
}
const QString sessionId = qEnvironmentVariable("XDG_SESSION_ID", QStringLiteral("auto"));
QDBusMessage message = QDBusMessage::createMethodCall(s_serviceName, s_managerPath,
s_managerInterface,
QStringLiteral("GetSession"));
message.setArguments({sessionId});
const QDBusMessage reply = QDBusConnection::systemBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
return QString();