From 401773a463992f926086b178caff14dd55dbd148 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 14 Apr 2020 22:00:20 +0300 Subject: [PATCH] protocol: agl-shell-desktop: Send notification for application state change The events are sent straight after the activation took place. The state changes are the surface role (for instance, pop-up) and the activate/de-activate type of event. With that information there's also a string type of data which can be used as easy way to forward data. Note that this isn't the proper way for applications to communicate with each other, but merely as a convenient way to pass data from one application to another. In order to hang-off the data, the 'activate_app' request also got an additional argument which is relayed back with the event. Bug-AGL: SPEC-3269 Signed-off-by: Marius Vlad Change-Id: I0c9be86f6ff227b59271cac1c060563b5aac9b6c --- protocol/agl-shell-desktop.xml | 17 ++++++++++++++++ src/ivi-compositor.h | 3 +++ src/layout.c | 5 +++-- src/shell.c | 46 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/protocol/agl-shell-desktop.xml b/protocol/agl-shell-desktop.xml index 6d53f92..05a3725 100644 --- a/protocol/agl-shell-desktop.xml +++ b/protocol/agl-shell-desktop.xml @@ -37,6 +37,11 @@ + + + + + The compositor may choose to advertise one or more application ids which @@ -58,6 +63,7 @@ description of app_id. + @@ -92,5 +98,16 @@ + + + + Notifies application(s) when other application have suffered state modifications. + + + + + + + diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h index b76da85..91b5340 100644 --- a/src/ivi-compositor.h +++ b/src/ivi-compositor.h @@ -273,6 +273,9 @@ ivi_layout_set_position(struct ivi_surface *surface, int32_t x, int32_t y, int32_t width, int32_t height); +struct ivi_surface * +ivi_find_app(struct ivi_compositor *ivi, const char *app_id); + void ivi_layout_commit(struct ivi_compositor *ivi); diff --git a/src/layout.c b/src/layout.c index 6f6c763..629290f 100644 --- a/src/layout.c +++ b/src/layout.c @@ -32,6 +32,8 @@ #include #include +#include "agl-shell-desktop-server-protocol.h" + #define AGL_COMP_DEBUG static void @@ -165,7 +167,7 @@ ivi_layout_init(struct ivi_compositor *ivi, struct ivi_output *output) output->area.x, output->area.y); } -static struct ivi_surface * +struct ivi_surface * ivi_find_app(struct ivi_compositor *ivi, const char *app_id) { struct ivi_surface *surf; @@ -470,7 +472,6 @@ ivi_layout_activate(struct ivi_output *output, const char *app_id) /* force repaint of the entire output */ weston_output_damage(output->output); } - } static struct ivi_output * diff --git a/src/shell.c b/src/shell.c index 768b6d2..aa63b86 100644 --- a/src/shell.c +++ b/src/shell.c @@ -509,6 +509,29 @@ shell_set_panel(struct wl_client *client, weston_desktop_surface_set_size(dsurface, width, height); } + +static void +shell_advertise_app_state(struct ivi_compositor *ivi, const char *app_id, + const char *data, uint32_t app_state) +{ + struct desktop_client *dclient; + uint32_t app_role; + struct ivi_surface *surf = ivi_find_app(ivi, app_id); + + /* FIXME: should queue it here and see when binding agl-shell-desktop + * if there are any to be sent */ + if (!surf) + return; + + app_role = surf->role; + if (app_role == IVI_SURFACE_ROLE_POPUP) + app_role = AGL_SHELL_DESKTOP_APP_ROLE_POPUP; + + wl_list_for_each(dclient, &ivi->desktop_clients, link) + agl_shell_desktop_send_state_app(dclient->resource, app_id, + data, app_state, app_role); +} + static void shell_activate_app(struct wl_client *client, struct wl_resource *shell_res, @@ -522,13 +545,32 @@ shell_activate_app(struct wl_client *client, ivi_layout_activate(output, app_id); } +static void +shell_desktop_activate_app(struct wl_client *client, + struct wl_resource *shell_res, + const char *app_id, const char *data, + struct wl_resource *output_res) +{ + struct weston_head *head = weston_head_from_resource(output_res); + struct weston_output *woutput = weston_head_get_output(head); + struct ivi_output *output = to_ivi_output(woutput); + + ivi_layout_activate(output, app_id); + shell_advertise_app_state(output->ivi, app_id, + data, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED); +} + static void shell_deactivate_app(struct wl_client *client, struct wl_resource *shell_res, const char *app_id) { struct desktop_client *dclient = wl_resource_get_user_data(shell_res); - ivi_layout_deactivate(dclient->ivi, app_id); + struct ivi_compositor *ivi = dclient->ivi; + + ivi_layout_deactivate(ivi, app_id); + shell_advertise_app_state(ivi, app_id, + NULL, AGL_SHELL_DESKTOP_APP_STATE_DEACTIVATED); } static const struct agl_shell_interface agl_shell_implementation = { @@ -554,7 +596,7 @@ shell_desktop_set_app_property(struct wl_client *client, } static const struct agl_shell_desktop_interface agl_shell_desktop_implementation = { - .activate_app = shell_activate_app, + .activate_app = shell_desktop_activate_app, .set_app_property = shell_desktop_set_app_property, .deactivate_app = shell_deactivate_app, }; -- 2.16.6