~lukas-kde/qtmir/betterSessionManagement

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/application.cpp

  • Committer: Lukáš Tinkl
  • Date: 2017-03-24 11:51:00 UTC
  • mfrom: (590.1.35 qtmir)
  • Revision ID: lukas.tinkl@canonical.com-20170324115100-n0itqdupc26qe6g6
merge trunk, resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
namespace unityapp = unity::shell::application;
37
37
 
38
38
#define DEBUG_MSG qCDebug(QTMIR_APPLICATIONS).nospace() << "Application[" << appId() <<"]::" << __func__
 
39
#define INFO_MSG qCInfo(QTMIR_APPLICATIONS).nospace() << "Application[" << appId() <<"]::" << __func__
39
40
 
40
41
namespace qtmir
41
42
{
59
60
    , m_proxySurfaceList(new ProxySurfaceListModel(this))
60
61
    , m_proxyPromptSurfaceList(new ProxySurfaceListModel(this))
61
62
{
62
 
    DEBUG_MSG << "()";
 
63
    INFO_MSG << "()";
63
64
 
64
65
    // Because m_state is InternalState::Starting
65
66
    acquireWakelock();
75
76
 
76
77
Application::~Application()
77
78
{
78
 
    DEBUG_MSG << "()";
 
79
    INFO_MSG << "()";
79
80
 
80
81
    // (ricmm) -- To be on the safe side, better wipe the application QML compile cache if it crashes on startup
81
82
    if (m_processState == Application::ProcessUnknown) {
276
277
        return;
277
278
    }
278
279
 
279
 
    DEBUG_MSG << "(requestedState=" << applicationStateToStr(value) << ")";
 
280
    INFO_MSG << "(requestedState=" << applicationStateToStr(value) << ")";
280
281
 
281
282
    m_requestedState = value;
282
283
    Q_EMIT requestedStateChanged(m_requestedState);
430
431
 
431
432
void Application::close()
432
433
{
433
 
    DEBUG_MSG << "()";
 
434
    INFO_MSG << "()";
434
435
 
435
436
    switch (m_state) {
436
437
    case InternalState::Starting:
480
481
 
481
482
void Application::setSession(SessionInterface *newSession)
482
483
{
483
 
    DEBUG_MSG << "(session=" << newSession << ")";
 
484
    INFO_MSG << "(session=" << newSession << ")";
484
485
 
485
486
    if (newSession == m_session)
486
487
        return;
549
550
        return;
550
551
    }
551
552
 
552
 
    DEBUG_MSG << "(state=" << internalStateToStr(state) << ")";
 
553
    INFO_MSG << "(state=" << internalStateToStr(state) << ")";
553
554
 
554
555
    auto oldPublicState = this->state();
555
556
    m_state = state;
644
645
 
645
646
void Application::suspend()
646
647
{
647
 
    DEBUG_MSG << "()";
 
648
    INFO_MSG << "()";
648
649
 
649
650
    Q_ASSERT(m_state == InternalState::Running);
650
651
    Q_ASSERT(m_session != nullptr);
662
663
 
663
664
void Application::resume()
664
665
{
665
 
    DEBUG_MSG << "()";
 
666
    INFO_MSG << "()";
666
667
 
667
668
    if (m_state == InternalState::Suspended || m_state == InternalState::SuspendingWaitProcess) {
668
669
        Q_EMIT resumeProcessRequested();
683
684
 
684
685
void Application::respawn()
685
686
{
686
 
    DEBUG_MSG << "()";
 
687
    INFO_MSG << "()";
687
688
 
688
689
    setInternalState(InternalState::Starting);
689
690
 
692
693
 
693
694
void Application::stop()
694
695
{
695
 
    DEBUG_MSG << "()";
 
696
    INFO_MSG << "()";
696
697
 
697
698
    Q_EMIT stopProcessRequested();
698
699
}
711
712
{
712
713
    if (m_exemptFromLifecycle != exemptFromLifecycle)
713
714
    {
714
 
        DEBUG_MSG << "(" << exemptFromLifecycle << ")";
 
715
        INFO_MSG << "(" << exemptFromLifecycle << ")";
715
716
        // We don't adjust current suspension state, we only care about exempt
716
717
        // status going into a suspend.
717
718
        m_exemptFromLifecycle = exemptFromLifecycle;
870
871
void Application::requestFocus()
871
872
{
872
873
    if (m_proxySurfaceList->rowCount() > 0) {
873
 
        DEBUG_MSG << "() - Requesting focus for most recent app surface";
 
874
        INFO_MSG << "() - Requesting focus for most recent app surface";
874
875
        auto surface = static_cast<MirSurfaceInterface*>(m_proxySurfaceList->get(0));
875
876
        surface->requestFocus();
876
877
    } else {
877
 
        DEBUG_MSG << "() - emitting focusRequested()";
 
878
        INFO_MSG << "() - emitting focusRequested()";
878
879
        Q_EMIT focusRequested();
879
880
    }
880
881
}