on xenial help sign in
Pass qtmir whether an app is exempt from the lifecycle or not
commitc6ccdb7279b23e5587297707d298fbba5612a251 authorMichael Terry <michael.terry@canonical.com> dateThu 3 Dec 2015, 13:10 (11 years ago) parent6f193bd
10 files changed+54−24
CMakeLists.txt+1−1 debian/control+3−3 qml/Stages/PhoneStage.qml+6−4 qml/Stages/TabletStage.qml+6−4 tests/mocks/Unity/Application/ApplicationInfo.cpp+16 tests/mocks/Unity/Application/ApplicationInfo.h+4 tests/mocks/Unity/Application/ApplicationManager.cpp+2 tests/mocks/Unity/Application/ApplicationManager.h+1−1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+2 tests/qmltests/tst_Shell.qml+13−11
CMakeLists.txt+1−1
@@ -57,7 +57,7 @@ find_package(Qt5DBus 5.4 REQUIRED)
5757find_package(Qt5Concurrent 5.4 REQUIRED)
5858find_package(Qt5Sql 5.4 REQUIRED)
5959
60−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=11)
60+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=12)
6161
6262# Standard install paths
6363include(GNUInstallDirs)
debian/control+3−3
@@ -29,7 +29,7 @@ Build-Depends: cmake,
2929 libqt5xmlpatterns5-dev,
3030 libsystemsettings-dev,
3131 libudev-dev,
32− libunity-api-dev (>= 7.103),
32+ libunity-api-dev (>= 7.104),
3333 libusermetricsoutput1-dev,
3434 libxcb1-dev,
3535 pkg-config,
@@ -128,7 +128,7 @@ Depends: qml-module-qtquick-layouts,
128128 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1627) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1627),
129129 qtdeclarative5-unity-notifications-plugin (>= 0.1.2) | unity-notifications-impl,
130130 ubuntu-thumbnailer-impl-0,
131− unity-application-impl-11,
131+ unity-application-impl-12,
132132 unity-notifications-impl-3,
133133 unity-plugin-scopes | unity-scopes-impl,
134134 unity-scopes-impl-7,
@@ -174,7 +174,7 @@ Pre-Depends: ${misc:Pre-Depends},
174174Depends: ${misc:Depends},
175175 ${shlibs:Depends},
176176Provides: unity-application-impl,
177− unity-application-impl-11,
177+ unity-application-impl-12,
178178Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1)
179179Description: Fake environment for running Unity 8 shell
180180 Provides fake implementations of some QML modules used by Unity 8 shell
qml/Stages/PhoneStage.qml+6−4
@@ -426,14 +426,16 @@ AbstractStage {
426426
427427 readonly property bool isDash: model.appId == "unity8-dash"
428428
429− readonly property bool canSuspend: model.isTouchApp
430− && !isExemptFromLifecycle(model.appId)
429+ Binding {
430+ target: appDelegate.application
431+ property: "exemptFromLifecycle"
432+ value: !model.isTouchApp || isExemptFromLifecycle(model.appId)
433+ }
431434
432435 Binding {
433436 target: appDelegate.application
434437 property: "requestedState"
435− value: !canSuspend
436− || (isDash && root.keepDashRunning)
438+ value: (isDash && root.keepDashRunning)
437439 || (!root.suspended && appDelegate.focus)
438440 ? ApplicationInfoInterface.RequestedRunning
439441 : ApplicationInfoInterface.RequestedSuspended
qml/Stages/TabletStage.qml+6−4
@@ -612,14 +612,16 @@ AbstractStage {
612612
613613 readonly property bool isDash: model.appId == "unity8-dash"
614614
615− readonly property bool canSuspend: model.isTouchApp
616− && !isExemptFromLifecycle(model.appId)
615+ Binding {
616+ target: spreadTile.application
617+ property: "exemptFromLifecycle"
618+ value: !model.isTouchApp || isExemptFromLifecycle(model.appId)
619+ }
617620
618621 Binding {
619622 target: spreadTile.application
620623 property: "requestedState"
621− value: !canSuspend
622− || (isDash && root.keepDashRunning)
624+ value: (isDash && root.keepDashRunning)
623625 || (!root.suspended && (model.appId == priv.mainStageAppId
624626 || model.appId == priv.sideStageAppId))
625627 ? ApplicationInfoInterface.RequestedRunning
tests/mocks/Unity/Application/ApplicationInfo.cpp+16
@@ -42,6 +42,7 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
4242 , m_rotatesWindowContents(false)
4343 , m_requestedState(RequestedRunning)
4444 , m_isTouchApp(true)
45+ , m_exemptFromLifecycle(false)
4546 , m_manualSurfaceCreation(false)
4647{
4748}
@@ -60,6 +61,7 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
6061 , m_rotatesWindowContents(false)
6162 , m_requestedState(RequestedRunning)
6263 , m_isTouchApp(true)
64+ , m_exemptFromLifecycle(false)
6365 , m_manualSurfaceCreation(false)
6466{
6567}
@@ -253,6 +255,20 @@ void ApplicationInfo::setIsTouchApp(bool isTouchApp)
253255 m_isTouchApp = isTouchApp;
254256}
255257
258+bool ApplicationInfo::exemptFromLifecycle() const
259+{
260+ return m_exemptFromLifecycle;
261+}
262+
263+void ApplicationInfo::setExemptFromLifecycle(bool exemptFromLifecycle)
264+{
265+ if (m_exemptFromLifecycle != exemptFromLifecycle)
266+ {
267+ m_exemptFromLifecycle = exemptFromLifecycle;
268+ Q_EMIT exemptFromLifecycleChanged(m_exemptFromLifecycle);
269+ }
270+}
271+
256272void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
257273{
258274 if (surface != nullptr && m_state == Starting) {
tests/mocks/Unity/Application/ApplicationInfo.h+4
@@ -92,6 +92,9 @@ public:
9292 bool isTouchApp() const override;
9393 void setIsTouchApp(bool isTouchApp); // only in mock
9494
95+ bool exemptFromLifecycle() const override;
96+ void setExemptFromLifecycle(bool) override;
97+
9598public:
9699 void setSession(Session* session);
97100 Session* session() const { return m_session; }
@@ -125,6 +128,7 @@ private:
125128 bool m_rotatesWindowContents;
126129 RequestedState m_requestedState;
127130 bool m_isTouchApp;
131+ bool m_exemptFromLifecycle;
128132
129133 bool m_manualSurfaceCreation;
130134};
tests/mocks/Unity/Application/ApplicationManager.cpp+2
@@ -107,6 +107,8 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
107107 return app->focused();
108108 case RoleIsTouchApp:
109109 return app->isTouchApp();
110+ case RoleExemptFromLifecycle:
111+ return app->exemptFromLifecycle();
110112 case RoleSession:
111113 return QVariant::fromValue(app->session());
112114 case RoleFullscreen:
tests/mocks/Unity/Application/ApplicationManager.h+1−1
@@ -43,7 +43,7 @@ class ApplicationManager : public ApplicationManagerInterface {
4343 static ApplicationManager *singleton();
4444
4545 enum MoreRoles {
46− RoleSession = RoleIsTouchApp+1,
46+ RoleSession = RoleExemptFromLifecycle+1,
4747 RoleFullscreen,
4848 };
4949 enum Flag {
tests/plugins/Unity/Launcher/launchermodeltest.cpp+2
@@ -59,6 +59,8 @@ public:
5959 Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
6060 bool rotatesWindowContents() const override { return false; }
6161 bool isTouchApp() const override { return true; }
62+ bool exemptFromLifecycle() const override { return false; }
63+ void setExemptFromLifecycle(bool) override {}
6264
6365 // Methods used for mocking (not in the interface)
6466 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
tests/qmltests/tst_Shell.qml+13−11
@@ -1859,19 +1859,20 @@ Rectangle {
18591859
18601860 var app1 = ApplicationManager.startApplication("libreoffice");
18611861 waitUntilAppWindowIsFullyLoaded(app1);
1862− var app2 = ApplicationManager.startApplication("dialer-app");
1862+ var app2 = ApplicationManager.startApplication("gallery-app");
18631863 waitUntilAppWindowIsFullyLoaded(app2);
18641864
1865− // Make sure app1 is unfocused but still running
1866− compare(app1.session.surface.activeFocus, false);
1867− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1868− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1865+ // Make sure app1 is exempt with a requested suspend
1866+ verify(app1.exemptFromLifecycle);
1867+ verify(!app1.isTouchApp); // sanity check our mock, which sets this for us
1868+ verify(!app1.session.surface.activeFocus);
1869+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18691870 }
18701871
18711872 function test_lifecyclePolicyExemption_data() {
18721873 return [
1873− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1874− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1874+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1875+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
18751876 ]
18761877 }
18771878
@@ -1883,12 +1884,13 @@ Rectangle {
18831884
18841885 var app1 = ApplicationManager.startApplication("webbrowser-app");
18851886 waitUntilAppWindowIsFullyLoaded(app1);
1886− var app2 = ApplicationManager.startApplication("dialer-app");
1887+ var app2 = ApplicationManager.startApplication("gallery-app");
18871888 waitUntilAppWindowIsFullyLoaded(app2);
18881889
1889− // Make sure app1 is unfocused but still running
1890− compare(app1.session.surface.activeFocus, false);
1891− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1890+ // Make sure app1 is exempt with a requested suspend
1891+ verify(app1.exemptFromLifecycle);
1892+ verify(!app1.session.surface.activeFocus);
1893+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18921894 }
18931895
18941896 function test_switchToStagedForcesLegacyAppClosing_data() {