on xenial help sign in
Update to drop canSuspend and simply request different states based on info we have
846cd64Michael Terry
qml/Shell.qml+1−11
@@ -219,6 +219,7 @@ Item {
219 schema.id: "com.canonical.qtmir"
219 schema.id: "com.canonical.qtmir"
220 }
220 }
221
221
222+ // Used by stage code
222 function isExemptFromLifecycle(appId) {
223 function isExemptFromLifecycle(appId) {
223 var shortAppId = appId.split('_')[0];
224 var shortAppId = appId.split('_')[0];
224 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
225 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
@@ -258,17 +259,6 @@ Item {
258
259
259 onApplicationAdded: {
260 onApplicationAdded: {
260 launcher.hide();
261 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− }
272 }
262 }
273 }
263 }
274
264
qml/Stages/PhoneStage.qml+6−3
@@ -441,9 +441,12 @@ Rectangle {
441 Binding {
441 Binding {
442 target: appDelegate.application
442 target: appDelegate.application
443 property: "requestedState"
443 property: "requestedState"
444+ value: !model.isTouchApp
445+ || stages.isExemptFromLifecycle(model.appId)
446+ || (isDash && root.keepDashRunning)
444− value: (isDash && root.keepDashRunning) || (!root.suspended && appDelegate.focus)
447+ || (!root.suspended && appDelegate.focus)
445− ? ApplicationInfoInterface.RequestedRunning
448+ ? ApplicationInfoInterface.RequestedRunning
446− : ApplicationInfoInterface.RequestedSuspended
449+ : ApplicationInfoInterface.RequestedSuspended
447 }
450 }
448
451
449 readonly property bool isDash: model.appId == "unity8-dash"
452 readonly property bool isDash: model.appId == "unity8-dash"
qml/Stages/TabletStage.qml+7−6
@@ -632,12 +632,13 @@ Rectangle {
632 Binding {
632 Binding {
633 target: spreadTile.application
633 target: spreadTile.application
634 property: "requestedState"
634 property: "requestedState"
635+ value: !model.isTouchApp
636+ || stages.isExemptFromLifecycle(model.appId)
635− value: (spreadTile.isDash && root.keepDashRunning)
637+ || (isDash && root.keepDashRunning)
636− ||
637− (!root.suspended && (model.appId == priv.mainStageAppId
638+ || (!root.suspended && (model.appId == priv.mainStageAppId
638− || model.appId == priv.sideStageAppId))
639+ || model.appId == priv.sideStageAppId))
639− ? ApplicationInfoInterface.RequestedRunning
640+ ? ApplicationInfoInterface.RequestedRunning
640− : ApplicationInfoInterface.RequestedSuspended
641+ : ApplicationInfoInterface.RequestedSuspended
641 }
642 }
642
643
643 // FIXME: A regular binding doesn't update any more after closing an app.
644 // 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)
42 , m_rotatesWindowContents(false)
42 , m_rotatesWindowContents(false)
43 , m_requestedState(RequestedRunning)
43 , m_requestedState(RequestedRunning)
44 , m_isTouchApp(true)
44 , m_isTouchApp(true)
45− , m_canSuspend(true)
46 , m_manualSurfaceCreation(false)
45 , m_manualSurfaceCreation(false)
47{
46{
48}
47}
@@ -61,7 +60,6 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
61 , m_rotatesWindowContents(false)
60 , m_rotatesWindowContents(false)
62 , m_requestedState(RequestedRunning)
61 , m_requestedState(RequestedRunning)
63 , m_isTouchApp(true)
62 , m_isTouchApp(true)
64− , m_canSuspend(true)
65 , m_manualSurfaceCreation(false)
63 , m_manualSurfaceCreation(false)
66{
64{
67}
65}
@@ -259,17 +257,6 @@ void ApplicationInfo::setIsTouchApp(bool isTouchApp)
259 m_isTouchApp = isTouchApp;
257 m_isTouchApp = isTouchApp;
260}
258}
261
259
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−
273void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
260void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
274{
261{
275 if (surface != nullptr && m_state == Starting) {
262 if (surface != nullptr && m_state == Starting) {
tests/mocks/Unity/Application/ApplicationInfo.h−4
@@ -92,9 +92,6 @@ public:
92 bool isTouchApp() const override;
92 bool isTouchApp() const override;
93 void setIsTouchApp(bool isTouchApp); // only in mock
93 void setIsTouchApp(bool isTouchApp); // only in mock
94
94
95− bool canSuspend() const override;
96− void setCanSuspend(bool canSuspend) override;
97−
98public:
95public:
99 void setSession(Session* session);
96 void setSession(Session* session);
100 Session* session() const { return m_session; }
97 Session* session() const { return m_session; }
@@ -128,7 +125,6 @@ private:
128 bool m_rotatesWindowContents;
125 bool m_rotatesWindowContents;
129 RequestedState m_requestedState;
126 RequestedState m_requestedState;
130 bool m_isTouchApp;
127 bool m_isTouchApp;
131− bool m_canSuspend;
132
128
133 bool m_manualSurfaceCreation;
129 bool m_manualSurfaceCreation;
134};
130};
tests/mocks/Unity/Application/ApplicationManager.cpp+2
@@ -105,6 +105,8 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
105 return app->state();
105 return app->state();
106 case RoleFocused:
106 case RoleFocused:
107 return app->focused();
107 return app->focused();
108+ case RoleIsTouchApp:
109+ return app->isTouchApp();
108 case RoleSession:
110 case RoleSession:
109 return QVariant::fromValue(app->session());
111 return QVariant::fromValue(app->session());
110 case RoleFullscreen:
112 case RoleFullscreen:
tests/mocks/Unity/Application/ApplicationManager.h+1−1
@@ -43,7 +43,7 @@ class ApplicationManager : public ApplicationManagerInterface {
43 static ApplicationManager *singleton();
43 static ApplicationManager *singleton();
44
44
45 enum MoreRoles {
45 enum MoreRoles {
46− RoleSession = RoleFocused+1,
46+ RoleSession = RoleIsTouchApp+1,
47 RoleFullscreen,
47 RoleFullscreen,
48 };
48 };
49 enum Flag {
49 enum Flag {
tests/plugins/Unity/Launcher/launchermodeltest.cpp−2
@@ -58,8 +58,6 @@ public:
58 Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
58 Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
59 bool rotatesWindowContents() const override { return false; }
59 bool rotatesWindowContents() const override { return false; }
60 bool isTouchApp() const override { return true; }
60 bool isTouchApp() const override { return true; }
61− bool canSuspend() const override { return true; }
62− void setCanSuspend(bool) override {}
63
61
64 // Methods used for mocking (not in the interface)
62 // Methods used for mocking (not in the interface)
65 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
63 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
tests/qmltests/tst_Shell.qml+26−7
@@ -1734,20 +1734,39 @@ Rectangle {
1734 keyRelease(Qt.Key_Control);
1734 keyRelease(Qt.Key_Control);
1735 }
1735 }
1736
1736
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+
1737− function test_lifecyclePolicy() {
1745+ function test_lifecyclePolicy(data) {
1738− loadShell("desktop");
1746+ loadShell(data.formFactor);
1747+ shell.usageScenario = data.usageScenario;
1739
1748
1740 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1749 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1741
1750
1742 var app1 = ApplicationManager.startApplication("camera-app");
1751 var app1 = ApplicationManager.startApplication("camera-app");
1743− tryCompare(app1, "canSuspend", true);
1752+ waitUntilAppWindowIsFullyLoaded(app1);
1744−
1745 var app2 = ApplicationManager.startApplication("webbrowser-app");
1753 var app2 = ApplicationManager.startApplication("webbrowser-app");
1746− tryCompare(app2, "canSuspend", false);
1754+ waitUntilAppWindowIsFullyLoaded(app2);
1747−
1748 var app3 = ApplicationManager.startApplication("libreoffice");
1755 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+
1749 compare(app3.isTouchApp, false); // sanity check our mock, which sets this for us
1766 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);
1751 }
1770 }
1752 }
1771 }
1753}
1772}