~ci-train-bot/qtubuntu/qtubuntu-ubuntu-xenial-landing-057

« back to all changes in this revision

Viewing changes to src/ubuntumirclient/integration.cpp

  • Committer: CI Train Bot
  • Author(s): Daniel d'Andrada
  • Date: 2015-12-07 16:20:47 UTC
  • mfrom: (288.3.3 useApplicationStateAPI)
  • Revision ID: ci-train-bot@canonical.com-20151207162047-3plcq7ipbd4wephb
Implement support for application state

Adapted code contribution from Sam Segers.

Also brought QWindowSystemInterface::handleWindowActivated() calls together, so they are all made from the same part of the code to ease tracking. Fixes: #1504776
Approved by: PS Jenkins bot, Gerry Boland

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    Q_UNUSED(options)
47
47
    Q_UNUSED(context)
48
48
    DASSERT(context != NULL);
49
 
    QCoreApplication::postEvent(QCoreApplication::instance(),
50
 
                                new QEvent(QEvent::ApplicationActivate));
 
49
    if (qGuiApp->focusWindow()) {
 
50
        QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
 
51
    } else {
 
52
        QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
 
53
    }
51
54
}
52
55
 
53
56
static void aboutToStopCallback(UApplicationArchive *archive, void* context)
61
64
    } else {
62
65
        qWarning("UbuntuClientIntegration aboutToStopCallback(): no input context");
63
66
    }
64
 
    QCoreApplication::postEvent(QCoreApplication::instance(),
65
 
                                new QEvent(QEvent::ApplicationDeactivate));
 
67
    QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended);
66
68
}
67
69
 
68
70
UbuntuClientIntegration::UbuntuClientIntegration()
175
177
    case OpenGL:
176
178
        return true;
177
179
 
 
180
    case ApplicationState:
 
181
        return true;
 
182
 
178
183
    case ThreadedOpenGL:
179
184
        if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) {
180
185
            return true;