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
TEMPLATE = app
TARGET = homescreen
TEMPLATE = app
TARGET = homescreen
-QT = qml quick gui-private
+QT = qml quick gui-private dbus
CONFIG += c++11 link_pkgconfig wayland-scanner
PKGCONFIG += wayland-client
CONFIG += c++11 link_pkgconfig wayland-scanner
PKGCONFIG += wayland-client
+DBUS_INTERFACES = $$[QT_SYSROOT]/usr/share/dbus-1/interfaces/org.automotivelinux.AppLaunch.xml
+
SOURCES += \
src/main.cpp \
src/shell.cpp \
SOURCES += \
src/main.cpp \
src/shell.cpp \
src/mastervolume.h \
src/homescreenhandler.h
src/mastervolume.h \
src/homescreenhandler.h
OTHER_FILES += \
README.md
OTHER_FILES += \
README.md
#include <qpa/qplatformnativeinterface.h>
#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) :
void* HomescreenHandler::myThis = 0;
HomescreenHandler::HomescreenHandler(Shell *_aglShell, ApplicationLauncher *launcher, QObject *parent) :
aglShell(_aglShell)
{
mp_launcher = launcher;
aglShell(_aglShell)
{
mp_launcher = launcher;
+ applaunch_iface = new org::automotivelinux::AppLaunch(APPLAUNCH_DBUS_IFACE, APPLAUNCH_DBUS_OBJECT,
+ QDBusConnection::sessionBus(), this);
}
HomescreenHandler::~HomescreenHandler()
}
HomescreenHandler::~HomescreenHandler()
+ /*
+ * 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);
#if 0
mp_hs->registerCallback(nullptr, HomescreenHandler::onRep_static);
mp_launcher->setCurrent(application_id);
}
#endif
mp_launcher->setCurrent(application_id);
}
#endif
+
+ appStarted(application_id);
+
+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");
+}
#include <QObject>
#include "applicationlauncher.h"
#include <QObject>
#include "applicationlauncher.h"
+#include "applaunch_interface.h"
#include "shell.h"
#include <string>
#include "shell.h"
#include <string>
signals:
void showNotification(QString application_id, QString icon_path, QString text);
void showInformation(QString info);
signals:
void showNotification(QString application_id, QString icon_path, QString text);
void showInformation(QString info);
+
+public slots:
+ void appStarted(const QString& application_id);
+ void appTerminated(const QString& application_id);
+
private:
ApplicationLauncher *mp_launcher;
Shell *aglShell;
private:
ApplicationLauncher *mp_launcher;
Shell *aglShell;
+ org::automotivelinux::AppLaunch *applaunch_iface;
};
#endif // HOMESCREENHANDLER_H
};
#endif // HOMESCREENHANDLER_H