Commit a22ff36e authored by David Edmundson's avatar David Edmundson
Browse files

Fix session restore + kwin interaction race

KSMServer sets which session to use on startup
`KSmServer::restoreSession(QString)`

When the session is up and ready either systemd or plasma-session invoke
`restoreSession()` that actively starts restoring clients.

At some point we need to notify kwin which session we're using so that
it can handle restorng window properties such as the virtual desktop.

This was done in the first call, but this has no guarantee that kwin has
started yet. Without kwin getting the DBus call it has no information to
match up restoration information.

The state RestoringWMSession is dropped as it does nothing useful.

BUG: 442380
parent 62cc1359
......@@ -903,7 +903,6 @@ void KSMServer::restoreSession(const QString &sessionName)
#ifdef KSMSERVER_STARTUP_DEBUG1
t.start();
#endif
state = RestoringWMSession;
qCDebug(KSMSERVER) << "KSMServer::restoreSession " << sessionName;
KSharedConfig::Ptr config = KSharedConfig::openConfig();
......@@ -913,15 +912,6 @@ void KSMServer::restoreSession(const QString &sessionName)
int count = configSessionGroup.readEntry("count", 0);
appsToStart = count;
auto reply = m_kwinInterface->loadSession(sessionName);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
if (state == RestoringWMSession) {
state = Idle;
}
});
}
/*!
......@@ -931,7 +921,6 @@ void KSMServer::startDefaultSession()
{
if (state != Idle)
return;
state = RestoringWMSession;
#ifdef KSMSERVER_STARTUP_DEBUG1
t.start();
#endif
......@@ -949,11 +938,20 @@ void KSMServer::restoreSession()
setDelayedReply(true);
m_restoreSessionCall = message();
restoreLegacySession(KSharedConfig::openConfig().data());
lastAppStarted = 0;
lastIdStarted.clear();
state = KSMServer::Restoring;
tryRestoreNext();
auto reply = m_kwinInterface->loadSession(currentSession());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, reply](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
if (reply.isError()) {
qWarning() << "Failed to notify kwin of current session " << reply.error().message();
}
restoreLegacySession(KSharedConfig::openConfig().data());
tryRestoreNext();
});
}
void KSMServer::restoreSubSession(const QString &name)
......
......@@ -189,7 +189,6 @@ private:
enum State {
Idle,
RestoringWMSession,
Restoring,
Shutdown,
Checkpoint,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment