aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2022-09-22 16:50:11 +0300
committerMarius Vlad <marius.vlad@collabora.com>2022-09-22 18:46:37 +0300
commit52c767388614e2ec6fa26851840bf01d97c5d49e (patch)
tree7ef5838055892525e7e2ba30795444b5e594347c
parent98d13ef3af738ad9186b5c5a027e874d1bc1dfbc (diff)
homescreen: Add support for v3 of agl-shell protocol
This protocol update adds support for started/terminated/activate/deactive events sent by the compositor. With this change we remove support for agl-shell-desktop protocol and instead rely on this new protocol update. Bug-AGL: SPEC-4528 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I9eb2135c5331eea82635583e8ca7cdf4e41a3d5e
-rw-r--r--homescreen/homescreen.pro2
-rw-r--r--homescreen/src/homescreenhandler.cpp30
-rw-r--r--homescreen/src/main.cpp80
3 files changed, 51 insertions, 61 deletions
diff --git a/homescreen/homescreen.pro b/homescreen/homescreen.pro
index c713c76..16a01f6 100644
--- a/homescreen/homescreen.pro
+++ b/homescreen/homescreen.pro
@@ -51,7 +51,7 @@ RESOURCES += \
qml/qml.qrc
AGL_SHELL_PATH = $$system(pkg-config --variable=pkgdatadir agl-compositor-0.0.20-protocols)
-WAYLANDCLIENTSOURCES += $$AGL_SHELL_PATH/agl-shell.xml $$AGL_SHELL_PATH/agl-shell-desktop.xml
+WAYLANDCLIENTSOURCES += $$AGL_SHELL_PATH/agl-shell.xml
target.path = $${PREFIX}/usr/bin
target.files += $${OUT_PWD}/$${TARGET}
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp
index 16d65fb..920c054 100644
--- a/homescreen/src/homescreenhandler.cpp
+++ b/homescreen/src/homescreenhandler.cpp
@@ -51,20 +51,16 @@ void HomescreenHandler::tapShortcut(QString app_id)
{
HMI_DEBUG("HomeScreen","tapShortcut %s", app_id.toStdString().c_str());
- if (app_id == LAUNCHER_APP_ID)
- goto activate_app;
+ if (app_id == LAUNCHER_APP_ID) {
+ activateApp(app_id);
+ return;
+ }
if (!mp_applauncher_client->startApplication(app_id)) {
HMI_ERROR("HomeScreen","Unable to start application '%s'",
app_id.toStdString().c_str());
return;
}
-
-activate_app:
- if (mp_launcher) {
- mp_launcher->setCurrent(app_id);
- }
- activateApp(app_id);
}
/*
@@ -90,13 +86,16 @@ void HomescreenHandler::addAppToStack(const QString& app_id)
void HomescreenHandler::activateApp(const QString& app_id)
{
- struct agl_shell *agl_shell = aglShell->shell.get();
- QPlatformNativeInterface *native = qApp->platformNativeInterface();
- struct wl_output *output = getWlOutput(native, qApp->screens().first());
+ struct agl_shell *agl_shell = aglShell->shell.get();
+ QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ struct wl_output *output = getWlOutput(native, qApp->screens().first());
+
+ if (mp_launcher) {
+ mp_launcher->setCurrent(app_id);
+ }
- HMI_DEBUG("HomeScreen", "Activating application %s", app_id.toStdString().c_str());
- agl_shell_activate_app(agl_shell, app_id.toStdString().c_str(), output);
- addAppToStack(app_id);
+ HMI_DEBUG("HomeScreen", "Activating application %s", app_id.toStdString().c_str());
+ agl_shell_activate_app(agl_shell, app_id.toStdString().c_str(), output);
}
void HomescreenHandler::deactivateApp(const QString& app_id)
@@ -110,6 +109,9 @@ void HomescreenHandler::deactivateApp(const QString& app_id)
void HomescreenHandler::processAppStatusEvent(const QString &app_id, const QString &status)
{
+ HMI_DEBUG("HomeScreen", "Processing application %s, status %s",
+ app_id.toStdString().c_str(), status.toStdString().c_str());
+
if (status == "started") {
activateApp(app_id);
} else if (status == "terminated") {
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index 4a13607..8c3391f 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -29,7 +29,6 @@
#include <wayland-client.h>
#include "wayland-agl-shell-client-protocol.h"
-#include "wayland-agl-shell-desktop-client-protocol.h"
#include "shell.h"
#ifndef MIN
@@ -38,38 +37,13 @@
struct shell_data {
struct agl_shell *shell;
- struct agl_shell_desktop *shell_desktop;
+ HomescreenHandler *homescreenHandler;
bool wait_for_bound;
bool bound_ok;
int ver;
};
static void
-agl_shell_desktop_application(void *data,
- struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id)
-{
- HomescreenHandler *homescreenHandler = static_cast<HomescreenHandler *>(data);
-
- if (homescreenHandler)
- homescreenHandler->addAppToStack(app_id);
-}
-
-static void
-agl_shell_desktop_state_app(void *data,
- struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id,
- const char *app_data,
- uint32_t state,
- uint32_t role)
-{
- HomescreenHandler *homescreenHandler = static_cast<HomescreenHandler *>(data);
-
- if (homescreenHandler && state == AGL_SHELL_DESKTOP_APP_STATE_DESTROYED)
- homescreenHandler->deactivateApp(app_id);
-}
-
-static void
agl_shell_bound_ok(void *data, struct agl_shell *agl_shell)
{
struct shell_data *shell_data = static_cast<struct shell_data *>(data);
@@ -87,18 +61,43 @@ agl_shell_bound_fail(void *data, struct agl_shell *agl_shell)
shell_data->bound_ok = false;
}
+static void
+agl_shell_app_state(void *data, struct agl_shell *agl_shell,
+ const char *app_id, uint32_t state)
+{
+ struct shell_data *shell_data = static_cast<struct shell_data *>(data);
+ HomescreenHandler *homescreenHandler = shell_data->homescreenHandler;
+
+ if (!homescreenHandler)
+ return;
+
+ switch (state) {
+ case AGL_SHELL_APP_STATE_STARTED:
+ qDebug() << "Got AGL_SHELL_APP_STATE_STARTED for app_id " << app_id;
+ homescreenHandler->processAppStatusEvent(app_id, "started");
+ break;
+ case AGL_SHELL_APP_STATE_TERMINATED:
+ qDebug() << "Got AGL_SHELL_APP_STATE_TERMINATED for app_id " << app_id;
+ // handled by HomescreenHandler::processAppStatusEvent
+ break;
+ case AGL_SHELL_APP_STATE_ACTIVATED:
+ qDebug() << "Got AGL_SHELL_APP_STATE_ACTIVATED for app_id " << app_id;
+ homescreenHandler->addAppToStack(app_id);
+ break;
+ default:
+ break;
+ }
+}
+
+
#ifdef AGL_SHELL_BOUND_OK_SINCE_VERSION
static const struct agl_shell_listener shell_listener = {
agl_shell_bound_ok,
agl_shell_bound_fail,
+ agl_shell_app_state,
};
#endif
-static const struct agl_shell_desktop_listener shell_desktop_listener = {
- agl_shell_desktop_application,
- agl_shell_desktop_state_app
-};
-
static void
global_add(void *data, struct wl_registry *reg, uint32_t name,
const char *interface, uint32_t ver)
@@ -112,7 +111,7 @@ global_add(void *data, struct wl_registry *reg, uint32_t name,
if (ver >= 2) {
shell_data->shell =
static_cast<struct agl_shell *>(
- wl_registry_bind(reg, name, &agl_shell_interface, MIN(2, ver)));
+ wl_registry_bind(reg, name, &agl_shell_interface, MIN(3, ver)));
#ifdef AGL_SHELL_BOUND_OK_SINCE_VERSION
agl_shell_add_listener(shell_data->shell, &shell_listener, data);
#endif
@@ -124,12 +123,6 @@ global_add(void *data, struct wl_registry *reg, uint32_t name,
shell_data->ver = ver;
}
-
- if (strcmp(interface, agl_shell_desktop_interface.name) == 0) {
- shell_data->shell_desktop = static_cast<struct agl_shell_desktop *>(
- wl_registry_bind(reg, name, &agl_shell_desktop_interface, 1)
- );
- }
}
static void
@@ -321,11 +314,6 @@ int main(int argc, char *argv[])
"Are you sure that agl-compositor is running?\n");
exit(EXIT_FAILURE);
}
- if (!shell_data.shell_desktop) {
- fprintf(stderr, "agl_shell_desktop extension is not advertised. "
- "Are you sure that agl-compositor is running?\n");
- exit(EXIT_FAILURE);
- }
qDebug() << "agl-shell interface is at version " << shell_data.ver;
if (shell_data.ver >= 2) {
@@ -352,9 +340,9 @@ int main(int argc, char *argv[])
ApplicationLauncher *launcher = new ApplicationLauncher();
launcher->setCurrent(QStringLiteral("launcher"));
- HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher);
- agl_shell_desktop_add_listener(shell_data.shell_desktop, &shell_desktop_listener, homescreenHandler);
+ HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher);
+ shell_data.homescreenHandler = homescreenHandler;
QQmlApplicationEngine engine;
QQmlContext *context = engine.rootContext();