on xenial help sign in
Update to drop canSuspend and simply request different states based on info we have
commit846cd64f5460558eb81279b85276196af435b64b authorMichael Terry <michael.terry@canonical.com> dateThu 1 Oct 2015, 13:43 (11 years ago) parent5db41f0
11 files changed+43−47
qml/Shell.qml+1−11 qml/Stages/PhoneStage.qml+6−3 qml/Stages/TabletStage.qml+7−6 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+1−11
@@ -219,6 +219,7 @@ Item {
219219 schema.id: "com.canonical.qtmir"
220220 }
221221
222+ // Used by stage code
222223 function isExemptFromLifecycle(appId) {
223224 var shortAppId = appId.split('_')[0];
224225 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
@@ -258,17 +259,6 @@ Item {
258259
259260 onApplicationAdded: {
260261 launcher.hide();
261−
262− // Apply lifecycle policy when an app is opened
263− var app = ApplicationManager.findApplication(appId);
264− if (app) {
265− // We don't bother with a Qt.binding because isTouchApp is
266− // marked as CONSTANT by unity-api, and we neither expect
267− // the gsettings to change on us during the life of the app,
268− // nor does it make a whole lot of sense to adjust the
269− // lifecycle policy while the app is running.
270− app.canSuspend = app.isTouchApp && !stages.isExemptFromLifecycle(appId);
271− }
272262 }
273263 }
274264
qml/Stages/PhoneStage.qml+6−3
@@ -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+ || stages.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/TabletStage.qml+7−6
@@ -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+ || stages.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}