~bregma/qtmir/use-ual-info

« back to all changes in this revision

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

  • Committer: CI Train Bot
  • Author(s): Nick Dedekind, Daniel d'Andrada
  • Date: 2015-12-10 13:08:27 UTC
  • mfrom: (345.5.18 qtmir)
  • Revision ID: ci-train-bot@canonical.com-20151210130827-k2129y6n1g2a5o2l
Politely asks processes to close before resorting to killing Fixes: #1434584
Approved by: Daniel d'Andrada

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
namespace qtmir
41
41
{
42
42
 
 
43
namespace {
 
44
 
 
45
const char *sessionStateToString(SessionInterface::State state)
 
46
{
 
47
    switch (state) {
 
48
    case SessionInterface::Starting:
 
49
        return "starting";
 
50
    case SessionInterface::Running:
 
51
        return "running";
 
52
    case SessionInterface::Suspending:
 
53
        return "suspending";
 
54
    case SessionInterface::Suspended:
 
55
        return "suspended";
 
56
    case SessionInterface::Stopped:
 
57
        return "stopped";
 
58
    default:
 
59
        return "???";
 
60
    }
 
61
}
 
62
 
 
63
}
 
64
 
43
65
Session::Session(const std::shared_ptr<ms::Session>& session,
44
66
                 const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager,
45
67
                 QObject *parent)
142
164
 
143
165
void Session::setState(State state) {
144
166
    if (state != m_state) {
 
167
        qCDebug(QTMIR_SESSIONS) << "Session::setState - session=" << name()
 
168
            << "state=" << sessionStateToString(state);
 
169
 
145
170
        m_state = state;
146
171
        Q_EMIT stateChanged(m_state);
147
172
    }
232
257
 
233
258
void Session::suspend()
234
259
{
235
 
    qCDebug(QTMIR_SESSIONS) << "Session::suspend - session=" << this << "state=" << applicationStateToStr(m_state);
 
260
    qCDebug(QTMIR_SESSIONS) << "Session::suspend - session=" << this << "state=" << sessionStateToString(m_state);
236
261
    if (m_state == Running) {
237
262
        session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);
238
263
        m_suspendTimer->start(1500);
251
276
 
252
277
void Session::resume()
253
278
{
254
 
    qCDebug(QTMIR_SESSIONS) << "Session::resume - session=" << this << "state=" << applicationStateToStr(m_state);
 
279
    qCDebug(QTMIR_SESSIONS) << "Session::resume - session=" << this << "state=" << sessionStateToString(m_state);
255
280
 
256
281
    if (m_state == Suspending || m_state == Suspended) {
257
282
        doResume();
281
306
    setState(Running);
282
307
}
283
308
 
 
309
void Session::close()
 
310
{
 
311
    qCDebug(QTMIR_SESSIONS) << "Session::close - " << name() << m_surface;
 
312
    if (m_surface) {
 
313
        m_surface->close();
 
314
    }
 
315
}
 
316
 
284
317
void Session::stop()
285
318
{
 
319
    qCDebug(QTMIR_SESSIONS) << "Session::stop - " << name();
 
320
 
286
321
    if (m_state != Stopped) {
 
322
 
287
323
        stopPromptSessions();
288
324
        if (m_suspendTimer->isActive())
289
325
            m_suspendTimer->stop();
304
340
void Session::setLive(const bool live)
305
341
{
306
342
    if (m_live != live) {
 
343
        qCDebug(QTMIR_SESSIONS) << "Session::setLive - " << name() << "live=" << live;
 
344
 
307
345
        m_live = live;
308
346
        Q_EMIT liveChanged(m_live);
309
347
        if (!live) {