Changeset View
Changeset View
Standalone View
Standalone View
ksmserver/startup.cpp
Show First 20 Lines • Show All 243 Lines • ▼ Show 20 Line(s) | 235 | { // wm failed to launch for some reason, go with kwin instead | |||
---|---|---|---|---|---|
244 | return; | 244 | return; | ||
245 | } | 245 | } | ||
246 | } | 246 | } | ||
247 | 247 | | |||
248 | void KSMServer::autoStart0() | 248 | void KSMServer::autoStart0() | ||
249 | { | 249 | { | ||
250 | if( state != LaunchingWM ) | 250 | if( state != LaunchingWM ) | ||
251 | return; | 251 | return; | ||
252 | if( !checkStartupSuspend()) | | |||
253 | return; | | |||
254 | state = AutoStart0; | 252 | state = AutoStart0; | ||
255 | #ifdef KSMSERVER_STARTUP_DEBUG1 | 253 | #ifdef KSMSERVER_STARTUP_DEBUG1 | ||
256 | qCDebug(KSMSERVER) << t.elapsed(); | 254 | qCDebug(KSMSERVER) << t.elapsed(); | ||
257 | #endif | 255 | #endif | ||
258 | 256 | | |||
259 | autoStart(0); | 257 | autoStart(0); | ||
260 | } | 258 | } | ||
261 | 259 | | |||
262 | void KSMServer::autoStart0Done() | 260 | void KSMServer::autoStart0Done() | ||
263 | { | 261 | { | ||
264 | if( state != AutoStart0 ) | 262 | if( state != AutoStart0 ) | ||
265 | return; | 263 | return; | ||
266 | if( !checkStartupSuspend()) | | |||
267 | return; | | |||
268 | qCDebug(KSMSERVER) << "Autostart 0 done"; | 264 | qCDebug(KSMSERVER) << "Autostart 0 done"; | ||
269 | #ifdef KSMSERVER_STARTUP_DEBUG1 | 265 | #ifdef KSMSERVER_STARTUP_DEBUG1 | ||
270 | qCDebug(KSMSERVER) << t.elapsed(); | 266 | qCDebug(KSMSERVER) << t.elapsed(); | ||
271 | #endif | 267 | #endif | ||
272 | 268 | | |||
273 | state = KcmInitPhase1; | 269 | state = KcmInitPhase1; | ||
274 | kcminitSignals = new QDBusInterface( QStringLiteral( "org.kde.kcminit"), | 270 | kcminitSignals = new QDBusInterface( QStringLiteral( "org.kde.kcminit"), | ||
275 | QStringLiteral( "/kcminit" ), | 271 | QStringLiteral( "/kcminit" ), | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
320 | #endif | 316 | #endif | ||
321 | autoStart(1); | 317 | autoStart(1); | ||
322 | } | 318 | } | ||
323 | 319 | | |||
324 | void KSMServer::autoStart1Done() | 320 | void KSMServer::autoStart1Done() | ||
325 | { | 321 | { | ||
326 | if( state != AutoStart1 ) | 322 | if( state != AutoStart1 ) | ||
327 | return; | 323 | return; | ||
328 | if( !checkStartupSuspend()) | | |||
329 | return; | | |||
330 | qCDebug(KSMSERVER) << "Autostart 1 done"; | 324 | qCDebug(KSMSERVER) << "Autostart 1 done"; | ||
331 | setupShortcuts(); // done only here, because it needs kglobalaccel :-/ | 325 | setupShortcuts(); // done only here, because it needs kglobalaccel :-/ | ||
332 | lastAppStarted = 0; | 326 | lastAppStarted = 0; | ||
333 | lastIdStarted.clear(); | 327 | lastIdStarted.clear(); | ||
334 | state = Restoring; | 328 | state = Restoring; | ||
335 | #ifdef KSMSERVER_STARTUP_DEBUG1 | 329 | #ifdef KSMSERVER_STARTUP_DEBUG1 | ||
336 | qCDebug(KSMSERVER)<< t.elapsed(); | 330 | qCDebug(KSMSERVER)<< t.elapsed(); | ||
337 | #endif | 331 | #endif | ||
Show All 10 Lines | 341 | if ( previousId && lastIdStarted == QString::fromLocal8Bit( previousId ) ) | |||
348 | tryRestoreNext(); | 342 | tryRestoreNext(); | ||
349 | } | 343 | } | ||
350 | 344 | | |||
351 | void KSMServer::tryRestoreNext() | 345 | void KSMServer::tryRestoreNext() | ||
352 | { | 346 | { | ||
353 | if( state != Restoring && state != RestoringSubSession ) | 347 | if( state != Restoring && state != RestoringSubSession ) | ||
354 | return; | 348 | return; | ||
355 | restoreTimer.stop(); | 349 | restoreTimer.stop(); | ||
356 | startupSuspendTimeoutTimer.stop(); | | |||
357 | KConfigGroup config(KSharedConfig::openConfig(), sessionGroup ); | 350 | KConfigGroup config(KSharedConfig::openConfig(), sessionGroup ); | ||
358 | 351 | | |||
359 | while ( lastAppStarted < appsToStart ) { | 352 | while ( lastAppStarted < appsToStart ) { | ||
360 | lastAppStarted++; | 353 | lastAppStarted++; | ||
361 | QString n = QString::number(lastAppStarted); | 354 | QString n = QString::number(lastAppStarted); | ||
362 | QString clientId = config.readEntry( QStringLiteral("clientId")+n, QString() ); | 355 | QString clientId = config.readEntry( QStringLiteral("clientId")+n, QString() ); | ||
363 | bool alreadyStarted = false; | 356 | bool alreadyStarted = false; | ||
364 | foreach ( KSMClient *c, clients ) { | 357 | foreach ( KSMClient *c, clients ) { | ||
Show All 36 Lines | 392 | else { //subsession | |||
401 | emit subSessionOpened(); | 394 | emit subSessionOpened(); | ||
402 | } | 395 | } | ||
403 | } | 396 | } | ||
404 | 397 | | |||
405 | void KSMServer::autoStart2() | 398 | void KSMServer::autoStart2() | ||
406 | { | 399 | { | ||
407 | if( state != Restoring ) | 400 | if( state != Restoring ) | ||
408 | return; | 401 | return; | ||
409 | if( !checkStartupSuspend()) | | |||
410 | return; | | |||
411 | state = FinishingStartup; | 402 | state = FinishingStartup; | ||
412 | #ifdef KSMSERVER_STARTUP_DEBUG1 | 403 | #ifdef KSMSERVER_STARTUP_DEBUG1 | ||
413 | qCDebug(KSMSERVER)<< t.elapsed(); | 404 | qCDebug(KSMSERVER)<< t.elapsed(); | ||
414 | #endif | 405 | #endif | ||
415 | waitAutoStart2 = true; | 406 | waitAutoStart2 = true; | ||
416 | waitKcmInit2 = true; | 407 | waitKcmInit2 = true; | ||
417 | autoStart(2); | 408 | autoStart(2); | ||
418 | 409 | | |||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | |||||
569 | #ifdef KSMSERVER_STARTUP_DEBUG1 | 560 | #ifdef KSMSERVER_STARTUP_DEBUG1 | ||
570 | qCDebug(KSMSERVER)<< t.elapsed(); | 561 | qCDebug(KSMSERVER)<< t.elapsed(); | ||
571 | #endif | 562 | #endif | ||
572 | 563 | | |||
573 | state = Idle; | 564 | state = Idle; | ||
574 | setupXIOErrorHandler(); // From now on handle X errors as normal shutdown. | 565 | setupXIOErrorHandler(); // From now on handle X errors as normal shutdown. | ||
575 | } | 566 | } | ||
576 | 567 | | |||
577 | bool KSMServer::checkStartupSuspend() | | |||
578 | { | | |||
579 | if( startupSuspendCount.isEmpty()) | | |||
580 | return true; | | |||
581 | // wait for the phase to finish | | |||
582 | if( !startupSuspendTimeoutTimer.isActive()) | | |||
583 | { | | |||
584 | startupSuspendTimeoutTimer.setSingleShot( true ); | | |||
585 | startupSuspendTimeoutTimer.start( 10000 ); | | |||
586 | } | | |||
587 | return false; | | |||
588 | } | | |||
589 | | ||||
590 | void KSMServer::suspendStartup( const QString &app ) | | |||
591 | { | | |||
592 | if( !startupSuspendCount.contains( app )) | | |||
593 | startupSuspendCount[ app ] = 0; | | |||
594 | ++startupSuspendCount[ app ]; | | |||
595 | } | | |||
596 | | ||||
597 | void KSMServer::resumeStartup( const QString &app ) | | |||
598 | { | | |||
599 | if( !startupSuspendCount.contains( app )) | | |||
600 | return; | | |||
601 | if( --startupSuspendCount[ app ] == 0 ) { | | |||
602 | startupSuspendCount.remove( app ); | | |||
603 | if( startupSuspendCount.isEmpty() && startupSuspendTimeoutTimer.isActive()) { | | |||
604 | startupSuspendTimeoutTimer.stop(); | | |||
605 | resumeStartupInternal(); | | |||
606 | } | | |||
607 | } | | |||
608 | } | | |||
609 | | ||||
610 | void KSMServer::startupSuspendTimeout() | | |||
611 | { | | |||
612 | qCDebug(KSMSERVER) << "Startup suspend timeout:" << state; | | |||
613 | resumeStartupInternal(); | | |||
614 | } | | |||
615 | | ||||
616 | void KSMServer::resumeStartupInternal() | | |||
617 | { | | |||
618 | startupSuspendCount.clear(); | | |||
619 | switch( state ) { | | |||
620 | case LaunchingWM: | | |||
621 | autoStart0(); | | |||
622 | break; | | |||
623 | case AutoStart0: | | |||
624 | autoStart0Done(); | | |||
625 | break; | | |||
626 | case AutoStart1: | | |||
627 | autoStart1Done(); | | |||
628 | break; | | |||
629 | case Restoring: | | |||
630 | autoStart2(); | | |||
631 | break; | | |||
632 | default: | | |||
633 | qCWarning(KSMSERVER) << "Unknown resume startup state" ; | | |||
634 | break; | | |||
635 | } | | |||
636 | } | | |||
637 | | ||||
638 | void KSMServer::upAndRunning( const QString& msg ) | 568 | void KSMServer::upAndRunning( const QString& msg ) | ||
639 | { | 569 | { | ||
640 | QDBusMessage ksplashProgressMessage = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KSplash"), | 570 | QDBusMessage ksplashProgressMessage = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KSplash"), | ||
641 | QStringLiteral("/KSplash"), | 571 | QStringLiteral("/KSplash"), | ||
642 | QStringLiteral("org.kde.KSplash"), | 572 | QStringLiteral("org.kde.KSplash"), | ||
643 | QStringLiteral("setStage")); | 573 | QStringLiteral("setStage")); | ||
644 | ksplashProgressMessage.setArguments(QList<QVariant>() << msg); | 574 | ksplashProgressMessage.setArguments(QList<QVariant>() << msg); | ||
645 | QDBusConnection::sessionBus().asyncCall(ksplashProgressMessage); | 575 | QDBusConnection::sessionBus().asyncCall(ksplashProgressMessage); | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |