Changeset View
Changeset View
Standalone View
Standalone View
ksmserver/logout.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | #include <KNotification> | 72 | #include <KNotification> | ||
73 | #include <kdisplaymanager.h> | 73 | #include <kdisplaymanager.h> | ||
74 | #include "server.h" | 74 | #include "server.h" | ||
75 | #include "global.h" | 75 | #include "global.h" | ||
76 | #include "client.h" | 76 | #include "client.h" | ||
77 | 77 | | |||
78 | #include "logoutprompt_interface.h" | 78 | #include "logoutprompt_interface.h" | ||
79 | #include "shutdown_interface.h" | 79 | #include "shutdown_interface.h" | ||
80 | #include "kwinsession_interface.h" | ||||
81 | | ||||
82 | enum KWinSessionState { | ||||
83 | Normal = 0, | ||||
84 | Saving = 1, | ||||
85 | Quitting = 2 | ||||
86 | }; | ||||
80 | 87 | | |||
81 | void KSMServer::logout( int confirm, int sdtype, int sdmode ) | 88 | void KSMServer::logout( int confirm, int sdtype, int sdmode ) | ||
82 | { | 89 | { | ||
83 | // KDE5: remove me | 90 | // KDE5: remove me | ||
84 | if (sdtype == KWorkSpace::ShutdownTypeLogout) | 91 | if (sdtype == KWorkSpace::ShutdownTypeLogout) | ||
85 | sdtype = KWorkSpace::ShutdownTypeNone; | 92 | sdtype = KWorkSpace::ShutdownTypeNone; | ||
86 | 93 | | |||
87 | shutdown( (KWorkSpace::ShutdownConfirm)confirm, | 94 | shutdown( (KWorkSpace::ShutdownConfirm)confirm, | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
178 | void KSMServer::performLogout() | 185 | void KSMServer::performLogout() | ||
179 | { | 186 | { | ||
180 | if( state >= Shutdown ) { // already performing shutdown | 187 | if( state >= Shutdown ) { // already performing shutdown | ||
181 | return; | 188 | return; | ||
182 | } | 189 | } | ||
183 | if (state != Idle) { | 190 | if (state != Idle) { | ||
184 | QTimer::singleShot(1000, this, &KSMServer::performLogout); | 191 | QTimer::singleShot(1000, this, &KSMServer::performLogout); | ||
185 | } | 192 | } | ||
193 | | ||||
194 | auto reply = m_kwinInterface->setState(KWinSessionState::Saving); | ||||
broulik: `reply` isn't actually used, remove? | |||||
195 | // we don't need to block as we wait for kwin to handle it's session 1 | ||||
196 | // before messaging the clients | ||||
197 | | ||||
186 | state = Shutdown; | 198 | state = Shutdown; | ||
187 | 199 | | |||
188 | // shall we save the session on logout? | 200 | // shall we save the session on logout? | ||
189 | KConfigGroup cg(KSharedConfig::openConfig(), "General"); | 201 | KConfigGroup cg(KSharedConfig::openConfig(), "General"); | ||
190 | saveSession = ( cg.readEntry( "loginMode", | 202 | saveSession = ( cg.readEntry( "loginMode", | ||
191 | QStringLiteral( "restorePreviousLogout" ) ) | 203 | QStringLiteral( "restorePreviousLogout" ) ) | ||
192 | == QLatin1String( "restorePreviousLogout" ) ); | 204 | == QLatin1String( "restorePreviousLogout" ) ); | ||
193 | 205 | | |||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
246 | { | 258 | { | ||
247 | if ( state != Idle ) | 259 | if ( state != Idle ) | ||
248 | return; | 260 | return; | ||
249 | 261 | | |||
250 | if ( currentSession().isEmpty() || currentSession() == QString::fromLocal8Bit( SESSION_PREVIOUS_LOGOUT ) ) | 262 | if ( currentSession().isEmpty() || currentSession() == QString::fromLocal8Bit( SESSION_PREVIOUS_LOGOUT ) ) | ||
251 | sessionGroup = QLatin1String("Session: ") + QString::fromLocal8Bit( SESSION_BY_USER ); | 263 | sessionGroup = QLatin1String("Session: ") + QString::fromLocal8Bit( SESSION_BY_USER ); | ||
252 | 264 | | |||
253 | state = Checkpoint; | 265 | state = Checkpoint; | ||
266 | | ||||
254 | wmPhase1WaitingCount = 0; | 267 | wmPhase1WaitingCount = 0; | ||
255 | saveType = SmSaveLocal; | 268 | saveType = SmSaveLocal; | ||
256 | saveSession = true; | 269 | saveSession = true; | ||
257 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | 270 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | ||
258 | performLegacySessionSave(); | 271 | performLegacySessionSave(); | ||
259 | #endif | 272 | #endif | ||
260 | foreach( KSMClient* c, clients ) { | 273 | foreach( KSMClient* c, clients ) { | ||
261 | c->resetState(); | 274 | c->resetState(); | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 412 | if( c->saveYourselfDone ) { | |||
400 | // Discard also saved state. | 413 | // Discard also saved state. | ||
401 | QStringList discard = c->discardCommand(); | 414 | QStringList discard = c->discardCommand(); | ||
402 | if( !discard.isEmpty()) | 415 | if( !discard.isEmpty()) | ||
403 | executeCommand( discard ); | 416 | executeCommand( discard ); | ||
404 | } | 417 | } | ||
405 | } | 418 | } | ||
406 | } | 419 | } | ||
407 | state = Idle; | 420 | state = Idle; | ||
421 | | ||||
422 | m_kwinInterface->setState(KWinSessionState::Normal); | ||||
423 | | ||||
408 | if (m_performLogoutCall.type() == QDBusMessage::MethodCallMessage) { | 424 | if (m_performLogoutCall.type() == QDBusMessage::MethodCallMessage) { | ||
409 | auto reply = m_performLogoutCall.createReply(false); | 425 | auto reply = m_performLogoutCall.createReply(false); | ||
410 | QDBusConnection::sessionBus().send(reply); | 426 | QDBusConnection::sessionBus().send(reply); | ||
411 | m_performLogoutCall = QDBusMessage(); | 427 | m_performLogoutCall = QDBusMessage(); | ||
412 | } | 428 | } | ||
413 | emit logoutCancelled(); | 429 | emit logoutCancelled(); | ||
414 | } | 430 | } | ||
415 | 431 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
514 | { | 530 | { | ||
515 | qCDebug(KSMSERVER) << "Starting killing clients"; | 531 | qCDebug(KSMSERVER) << "Starting killing clients"; | ||
516 | if (state == Killing) { | 532 | if (state == Killing) { | ||
517 | // we are already killing | 533 | // we are already killing | ||
518 | return; | 534 | return; | ||
519 | } | 535 | } | ||
520 | // kill all clients | 536 | // kill all clients | ||
521 | state = Killing; | 537 | state = Killing; | ||
538 | | ||||
539 | m_kwinInterface->setState(KWinSessionState::Quitting); | ||||
540 | | ||||
522 | foreach( KSMClient* c, clients ) { | 541 | foreach( KSMClient* c, clients ) { | ||
523 | if( isWM( c )) // kill the WM as the last one in order to reduce flicker | 542 | if( isWM( c )) // kill the WM as the last one in order to reduce flicker | ||
524 | continue; | 543 | continue; | ||
525 | qCDebug(KSMSERVER) << "startKilling: client " << c->program() << "(" << c->clientId() << ")"; | 544 | qCDebug(KSMSERVER) << "startKilling: client " << c->program() << "(" << c->clientId() << ")"; | ||
526 | SmsDie( c->connection() ); | 545 | SmsDie( c->connection() ); | ||
527 | } | 546 | } | ||
528 | 547 | | |||
529 | qCDebug(KSMSERVER) << " We killed all clients. We have now clients.count()=" << | 548 | qCDebug(KSMSERVER) << " We killed all clients. We have now clients.count()=" << | ||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |
reply isn't actually used, remove?