diff options
author | Arnaud Ferraris <arnaud.ferraris@collabora.com> | 2021-12-01 16:51:52 +0100 |
---|---|---|
committer | Arnaud Ferraris <arnaud.ferraris@collabora.com> | 2021-12-20 21:04:12 +0100 |
commit | fda3079ca8ff4a6ec6a67981ba1cdc56a8c0c3ab (patch) | |
tree | 8aa4fafd2f1bb18246ce7d94ce8911e143f9845b /homescreen/src/homescreenhandler.cpp | |
parent | 2b7ca7a6eeb79e03507abb7a16b0503591d2b064 (diff) |
homescreenhandler: use applaunchd for app activationmarlin_12.91.0marlin/12.91.012.91.0
As part of the App FW rework, we introduced a new app launcher service,
accessible through D-Bus. This service accepts requests to activate
applications, and notifies when a application successfully activated or
terminated.
Requests for activation are handled by a separate `launcher` application
for now, so we only need to listen on incoming signals in order to react
to those:
- when an application successfully started or is switched to, ask the
compositor to activate it
- when an application terminates, activate the launcher so the user
isn't facing a "blank" display
Bug-AGL: SPEC-4160
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Change-Id: I7369944570651b45ec9dcca9ccde3dfd75719c3b
Diffstat (limited to 'homescreen/src/homescreenhandler.cpp')
-rw-r--r-- | homescreen/src/homescreenhandler.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp index 836ed47..ee8d614 100644 --- a/homescreen/src/homescreenhandler.cpp +++ b/homescreen/src/homescreenhandler.cpp @@ -22,6 +22,9 @@ #include <qpa/qplatformnativeinterface.h> +#define APPLAUNCH_DBUS_IFACE "org.automotivelinux.AppLaunch" +#define APPLAUNCH_DBUS_OBJECT "/org/automotivelinux/AppLaunch" + void* HomescreenHandler::myThis = 0; HomescreenHandler::HomescreenHandler(Shell *_aglShell, ApplicationLauncher *launcher, QObject *parent) : @@ -29,6 +32,8 @@ HomescreenHandler::HomescreenHandler(Shell *_aglShell, ApplicationLauncher *laun aglShell(_aglShell) { mp_launcher = launcher; + applaunch_iface = new org::automotivelinux::AppLaunch(APPLAUNCH_DBUS_IFACE, APPLAUNCH_DBUS_OBJECT, + QDBusConnection::sessionBus(), this); } HomescreenHandler::~HomescreenHandler() @@ -48,6 +53,14 @@ void HomescreenHandler::init(void) #endif myThis = this; + /* + * The "started" signal is received any time a start request is made to applaunchd, + * and the application either starts successfully or is already running. This + * effectively acts as a "switch to app X" action. + */ + connect(applaunch_iface, SIGNAL(started(QString)), this, SLOT(appStarted(QString))); + connect(applaunch_iface, SIGNAL(terminated(QString)), this, SLOT(appTerminated(QString))); + #if 0 mp_hs->registerCallback(nullptr, HomescreenHandler::onRep_static); @@ -122,6 +135,8 @@ void HomescreenHandler::tapShortcut(QString application_id) mp_launcher->setCurrent(application_id); } #endif + + appStarted(application_id); } #if 0 @@ -155,3 +170,19 @@ void HomescreenHandler::onEv(const string& event, struct json_object* event_cont } } #endif + +void HomescreenHandler::appStarted(const QString& application_id) +{ + struct agl_shell *agl_shell = aglShell->shell.get(); + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + struct wl_output *output = getWlOutput(native, qApp->screens().first()); + + HMI_DEBUG("HomeScreen", "Activating application %s", application_id.toStdString().c_str()); + agl_shell_activate_app(agl_shell, application_id.toStdString().c_str(), output); +} + +void HomescreenHandler::appTerminated(const QString& application_id) +{ + HMI_DEBUG("HomeScreen", "Application %s terminated, activating launcher", application_id.toStdString().c_str()); + appStarted("launcher"); +} |