on xenial help sign in
merge prereq
commitc940cfc7ca3cf2332e669695044da2cf78082c8a authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 9 Oct 2015, 11:58 (11 years ago) parentb83f384e1261bc
14 files changed+84−65
qml/Shell.qml−25 qml/Stages/AbstractStage.qml+38 qml/Stages/DesktopStage.qml+1−1 qml/Stages/PhoneStage.qml+7−4 qml/Stages/ShimStage.qml+1−1 qml/Stages/TabletStage.qml+8−7 qml/graphics/applicationIcons/libreoffice@16.png qml/graphics/applicationIcons/libreoffice@18.png tests/mocks/Unity/Application/ApplicationInfo.cpp−13 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+26−7
qml/Shell.qml−25
@@ -214,20 +214,6 @@ Item {
214214 width: parent.width
215215 height: parent.height
216216
217− GSettings {
218− id: lifecycleExceptions
219− schema.id: "com.canonical.qtmir"
220− }
221−
222− function isExemptFromLifecycle(appId) {
223− for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
224− if (appId === lifecycleExceptions.lifecycleExemptAppids[i]) {
225− return true;
226− }
227− }
228− return false;
229− }
230−
231217 Connections {
232218 target: ApplicationManager
233219
@@ -257,17 +243,6 @@ Item {
257243
258244 onApplicationAdded: {
259245 launcher.hide();
260−
261− // Apply lifecycle policy when an app is opened
262− var app = ApplicationManager.findApplication(appId);
263− if (app) {
264− // We don't bother with a Qt.binding because isTouchApp is
265− // marked as CONSTANT by unity-api, and we neither expect
266− // the gsettings to change on us during the life of the app,
267− // nor does it make a whole lot of sense to adjust the
268− // lifecycle policy while the app is running.
269− app.canSuspend = app.isTouchApp && !stages.isExemptFromLifecycle(appId);
270− }
271246 }
272247 }
273248
qml/Stages/AbstractStage.qmlnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.2
19+import GSettings 1.0
20+
21+Rectangle {
22+ id: root
23+
24+ GSettings {
25+ id: lifecycleExceptions
26+ schema.id: "com.canonical.qtmir"
27+ }
28+
29+ function isExemptFromLifecycle(appId) {
30+ var shortAppId = appId.split('_')[0];
31+ for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
32+ if (shortAppId === lifecycleExceptions.lifecycleExemptAppids[i]) {
33+ return true;
34+ }
35+ }
36+ return false;
37+ }
38+}
qml/Stages/DesktopStage.qml+1−1
@@ -25,7 +25,7 @@ import "../Components/PanelState"
2525import Utils 0.1
2626import Ubuntu.Gestures 0.1
2727
28−Rectangle {
28+AbstractStage {
2929 id: root
3030 anchors.fill: parent
3131
qml/Stages/PhoneStage.qml+7−4
@@ -22,7 +22,7 @@ import Unity.Session 0.1
2222import Utils 0.1
2323import "../Components"
2424
25−Rectangle {
25+AbstractStage {
2626 id: root
2727
2828 // Controls to be set from outside
@@ -441,9 +441,12 @@ Rectangle {
441441 Binding {
442442 target: appDelegate.application
443443 property: "requestedState"
444− value: (isDash && root.keepDashRunning) || (!root.suspended && appDelegate.focus)
445− ? ApplicationInfoInterface.RequestedRunning
446− : ApplicationInfoInterface.RequestedSuspended
444+ value: !model.isTouchApp
445+ || isExemptFromLifecycle(model.appId)
446+ || (isDash && root.keepDashRunning)
447+ || (!root.suspended && appDelegate.focus)
448+ ? ApplicationInfoInterface.RequestedRunning
449+ : ApplicationInfoInterface.RequestedSuspended
447450 }
448451
449452 readonly property bool isDash: model.appId == "unity8-dash"
qml/Stages/ShimStage.qml+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.3
1818import Ubuntu.Components 0.1
1919
20−Rectangle {
20+AbstractStage {
2121 id: shimStage
2222
2323 anchors.fill: parent
qml/Stages/TabletStage.qml+8−7
@@ -21,7 +21,7 @@ import Unity.Application 0.1
2121import Utils 0.1
2222import "../Components"
2323
24−Rectangle {
24+AbstractStage {
2525 id: root
2626 objectName: "stages"
2727 anchors.fill: parent
@@ -632,12 +632,13 @@ Rectangle {
632632 Binding {
633633 target: spreadTile.application
634634 property: "requestedState"
635− value: (spreadTile.isDash && root.keepDashRunning)
636− ||
637− (!root.suspended && (model.appId == priv.mainStageAppId
638− || model.appId == priv.sideStageAppId))
639− ? ApplicationInfoInterface.RequestedRunning
640− : ApplicationInfoInterface.RequestedSuspended
635+ value: !model.isTouchApp
636+ || isExemptFromLifecycle(model.appId)
637+ || (isDash && root.keepDashRunning)
638+ || (!root.suspended && (model.appId == priv.mainStageAppId
639+ || model.appId == priv.sideStageAppId))
640+ ? ApplicationInfoInterface.RequestedRunning
641+ : ApplicationInfoInterface.RequestedSuspended
641642 }
642643
643644 // FIXME: A regular binding doesn't update any more after closing an app.
qml/graphics/applicationIcons/libreoffice@16.pngdeleted

Binary file not shown.

qml/graphics/applicationIcons/libreoffice@18.pngnew file

Binary file not shown.

tests/mocks/Unity/Application/ApplicationInfo.cpp−13
@@ -42,7 +42,6 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
4242 , m_rotatesWindowContents(false)
4343 , m_requestedState(RequestedRunning)
4444 , m_isTouchApp(true)
45− , m_canSuspend(true)
4645 , m_manualSurfaceCreation(false)
4746{
4847}
@@ -61,7 +60,6 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
6160 , m_rotatesWindowContents(false)
6261 , m_requestedState(RequestedRunning)
6362 , m_isTouchApp(true)
64− , m_canSuspend(true)
6563 , m_manualSurfaceCreation(false)
6664{
6765}
@@ -259,17 +257,6 @@ void ApplicationInfo::setIsTouchApp(bool isTouchApp)
259257 m_isTouchApp = isTouchApp;
260258}
261259
262−bool ApplicationInfo::canSuspend() const
263−{
264− return m_canSuspend;
265−}
266−
267−void ApplicationInfo::setCanSuspend(bool canSuspend)
268−{
269− m_canSuspend = canSuspend;
270− Q_EMIT canSuspendChanged(canSuspend);
271−}
272−
273260void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
274261{
275262 if (surface != nullptr && m_state == Starting) {
tests/mocks/Unity/Application/ApplicationInfo.h−4
@@ -92,9 +92,6 @@ public:
9292 bool isTouchApp() const override;
9393 void setIsTouchApp(bool isTouchApp); // only in mock
9494
95− bool canSuspend() const override;
96− void setCanSuspend(bool canSuspend) override;
97−
9895public:
9996 void setSession(Session* session);
10097 Session* session() const { return m_session; }
@@ -128,7 +125,6 @@ private:
128125 bool m_rotatesWindowContents;
129126 RequestedState m_requestedState;
130127 bool m_isTouchApp;
131− bool m_canSuspend;
132128
133129 bool m_manualSurfaceCreation;
134130};
tests/mocks/Unity/Application/ApplicationManager.cpp+2
@@ -105,6 +105,8 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
105105 return app->state();
106106 case RoleFocused:
107107 return app->focused();
108+ case RoleIsTouchApp:
109+ return app->isTouchApp();
108110 case RoleSession:
109111 return QVariant::fromValue(app->session());
110112 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 = RoleFocused+1,
46+ RoleSession = RoleIsTouchApp+1,
4747 RoleFullscreen,
4848 };
4949 enum Flag {
tests/plugins/Unity/Launcher/launchermodeltest.cpp−2
@@ -58,8 +58,6 @@ public:
5858 Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
5959 bool rotatesWindowContents() const override { return false; }
6060 bool isTouchApp() const override { return true; }
61− bool canSuspend() const override { return true; }
62− void setCanSuspend(bool) override {}
6361
6462 // Methods used for mocking (not in the interface)
6563 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
tests/qmltests/tst_Shell.qml+26−7
@@ -1734,20 +1734,39 @@ Rectangle {
17341734 keyRelease(Qt.Key_Control);
17351735 }
17361736
1737− function test_lifecyclePolicy() {
1738− loadShell("desktop");
1737+ function test_lifecyclePolicy_data() {
1738+ return [
1739+ {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1740+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true},
1741+ {tag: "desktop", formFactor: "tablet", usageScenario: "desktop", suspendsApps: false}
1742+ ]
1743+ }
1744+
1745+ function test_lifecyclePolicy(data) {
1746+ loadShell(data.formFactor);
1747+ shell.usageScenario = data.usageScenario;
17391748
17401749 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
17411750
17421751 var app1 = ApplicationManager.startApplication("camera-app");
1743− tryCompare(app1, "canSuspend", true);
1744−
1752+ waitUntilAppWindowIsFullyLoaded(app1);
17451753 var app2 = ApplicationManager.startApplication("webbrowser-app");
1746− tryCompare(app2, "canSuspend", false);
1747−
1754+ waitUntilAppWindowIsFullyLoaded(app2);
17481755 var app3 = ApplicationManager.startApplication("libreoffice");
1756+ waitUntilAppWindowIsFullyLoaded(app3);
1757+ var app4 = ApplicationManager.startApplication("dialer-app");
1758+ waitUntilAppWindowIsFullyLoaded(app4);
1759+
1760+ compare(app1.requestedState, data.suspendsApps ?
1761+ ApplicationInfoInterface.RequestedSuspended :
1762+ ApplicationInfoInterface.RequestedRunning);
1763+
1764+ compare(app2.requestedState, ApplicationInfoInterface.RequestedRunning);
1765+
17491766 compare(app3.isTouchApp, false); // sanity check our mock, which sets this for us
1750− tryCompare(app3, "canSuspend", false);
1767+ compare(app3.requestedState, ApplicationInfoInterface.RequestedRunning);
1768+
1769+ compare(app4.requestedState, ApplicationInfoInterface.RequestedRunning);
17511770 }
17521771 }
17531772}