Commit a9764a9b authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Clean up states and some comments

parent 269f5967
......@@ -226,7 +226,11 @@ void KSMServer::performLogout()
qCDebug(KSMSERVER) << "Telling KWin we're about to save session" << currentSession();
auto saveSessionCall = m_kwinInterface->aboutToSaveSession(currentSession());
saveSessionCall.waitForFinished(); // hehe
// We need to wait for KWin to save the initial state, e.g. active client and
// current desktop before we signal any clients to quit. They might bring up
// "Save changes?" prompts altering the state.
// KWin doesn't talk to KSMServer directly anymore, so this won't deadlock.
saveSessionCall.waitForFinished();
}
const auto pendingClients = clients;
......
......@@ -989,8 +989,7 @@ void KSMServer::setupShortcuts()
}
}
/*! Restores the previous session. Ensures the window manager is
running (if specified).
/*! Restores the previous session.
*/
void KSMServer::restoreSession( const QString &sessionName )
{
......@@ -999,7 +998,7 @@ void KSMServer::restoreSession( const QString &sessionName )
#ifdef KSMSERVER_STARTUP_DEBUG1
t.start();
#endif
state = LaunchingWM;
state = RestoringWMSession;
qCDebug(KSMSERVER) << "KSMServer::restoreSession " << sessionName;
KSharedConfig::Ptr config = KSharedConfig::openConfig();
......@@ -1011,19 +1010,23 @@ void KSMServer::restoreSession( const QString &sessionName )
appsToStart = count;
auto reply = m_kwinInterface->loadSession(sessionName);
reply.waitForFinished(); // boo!
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
if (state == RestoringWMSession) {
state = Idle;
}
});
}
/*!
Starts the default session.
Currently, that's the window manager only (if specified).
*/
void KSMServer::startDefaultSession()
{
if( state != Idle )
return;
state = LaunchingWM;
state = RestoringWMSession;
#ifdef KSMSERVER_STARTUP_DEBUG1
t.start();
#endif
......
......@@ -211,8 +211,8 @@ private:
enum State
{
Idle,
LaunchingWM /* FIXME rename this*/, Restoring,
Shutdown, Checkpoint, Killing, KillingWMDONTUSETHIS, WaitingForKNotify, // shutdown
RestoringWMSession, Restoring,
Shutdown, Checkpoint, Killing, WaitingForKNotify, // shutdown
ClosingSubSession, KillingSubSession, RestoringSubSession
};
State state;
......
Markdown is supported
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