summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Ferraris <arnaud.ferraris@collabora.com>2022-01-18 12:47:02 +0100
committerArnaud Ferraris <arnaud.ferraris@collabora.com>2022-01-20 17:25:38 +0100
commit20970d846906a070305d8e96cf0735bf7fd831b1 (patch)
tree2dc594f9436a6e57f4558af141075a7f920243e6
parent37ba3ff90d878a135e347508505657e3d56c5edd (diff)
homescreenhandler: keep track of active apps
When the current app window is closed, the current behavior depends on whether this action terminates the app: - if the app is terminated, then we switch back to the launcher - in the other case, we display the background, even if other apps are running In order to implement a better behavior, we should keep track of active apps and switch back to the previously active one when the current app window is closed. Bug-AGL: SPEC-4222 Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com> Change-Id: Idf1fe42886e95e2b37349b066204fde002d7c3b5
-rw-r--r--homescreen/src/homescreenhandler.cpp29
-rw-r--r--homescreen/src/homescreenhandler.h3
2 files changed, 30 insertions, 2 deletions
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp
index 4a8b9cd..5ed1fab 100644
--- a/homescreen/src/homescreenhandler.cpp
+++ b/homescreen/src/homescreenhandler.cpp
@@ -89,6 +89,27 @@ activate_app:
appStarted(application_id);
}
+/*
+ * Keep track of currently running apps and the order in which
+ * they were activated. That way, when an app is closed, we can
+ * switch back to the previously active one.
+ */
+void HomescreenHandler::addAppToStack(const QString& application_id)
+{
+ if (application_id == "homescreen")
+ return;
+
+ if (!apps_stack.contains(application_id)) {
+ apps_stack << application_id;
+ } else {
+ int current_pos = apps_stack.indexOf(application_id);
+ int last_pos = apps_stack.size() - 1;
+
+ if (current_pos != last_pos)
+ apps_stack.move(current_pos, last_pos);
+ }
+}
+
void HomescreenHandler::appStarted(const QString& application_id)
{
struct agl_shell *agl_shell = aglShell->shell.get();
@@ -97,10 +118,14 @@ void HomescreenHandler::appStarted(const QString& application_id)
HMI_DEBUG("HomeScreen", "Activating application %s", application_id.toStdString().c_str());
agl_shell_activate_app(agl_shell, application_id.toStdString().c_str(), output);
+ addAppToStack(application_id);
}
void HomescreenHandler::appTerminated(const QString& application_id)
{
- HMI_DEBUG("HomeScreen", "Application %s terminated, activating launcher", application_id.toStdString().c_str());
- appStarted("launcher");
+ HMI_DEBUG("HomeScreen", "Application %s terminated, activating last app", application_id.toStdString().c_str());
+ if (apps_stack.contains(application_id)) {
+ apps_stack.removeOne(application_id);
+ appStarted(apps_stack.last());
+ }
}
diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h
index d94740b..503221a 100644
--- a/homescreen/src/homescreenhandler.h
+++ b/homescreen/src/homescreenhandler.h
@@ -48,6 +48,8 @@ public:
static void onEv_static(const string& event, struct json_object* event_contents);
#endif
+ void addAppToStack(const QString& application_id);
+
signals:
void showNotification(QString application_id, QString icon_path, QString text);
void showInformation(QString info);
@@ -60,6 +62,7 @@ private:
ApplicationLauncher *mp_launcher;
Shell *aglShell;
org::automotivelinux::AppLaunch *applaunch_iface;
+ QStringList apps_stack;
};
#endif // HOMESCREENHANDLER_H