src/shell: Add a wrappers for sending events with agl-shell
authorMarius Vlad <marius.vlad@collabora.com>
Tue, 18 Oct 2022 20:32:40 +0000 (23:32 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Fri, 21 Oct 2022 17:16:53 +0000 (20:16 +0300)
As we now have one more (shell) client that can bind to agl-shell, add a
wrapper for sending the events and include it as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I869b036d6f24beeb3089bfd24b8d233c5fada71f

src/desktop.c
src/ivi-compositor.h
src/layout.c
src/shell.c

index 0e71de9..dfcc24d 100644 (file)
@@ -369,12 +369,8 @@ skip_output_asignment:
        if (app_id && output) {
                shell_advertise_app_state(output->ivi, app_id,
                                          NULL, AGL_SHELL_DESKTOP_APP_STATE_DESTROYED);
-
-               if (output->ivi->shell_client.ready &&
-                   wl_resource_get_version(output->ivi->shell_client.resource)
-                   >= AGL_SHELL_APP_STATE_SINCE_VERSION)
-                       agl_shell_send_app_state(output->ivi->shell_client.resource,
-                                                app_id, AGL_SHELL_APP_STATE_TERMINATED);
+               if (output->ivi->shell_client.ready)
+                       shell_send_app_state(output->ivi, app_id, AGL_SHELL_APP_STATE_TERMINATED);
        }
 
        wl_list_remove(&surface->link);
@@ -407,9 +403,7 @@ desktop_committed(struct weston_desktop_surface *dsurface,
                /* we'll do it now at commit time, because we might not have an
                 * appid by the time we've created the weston_desktop_surface
                 * */
-               if (wl_resource_get_version(ivi->shell_client.resource) >= AGL_SHELL_APP_STATE_SINCE_VERSION)
-                       agl_shell_send_app_state(ivi->shell_client.resource,
-                                                app_id, AGL_SHELL_APP_STATE_STARTED);
+               shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_STARTED);
        }
 
        if (!surface->advertised_on_launch &&
index 1d03747..889c3f3 100644 (file)
@@ -498,4 +498,8 @@ ivi_shell_activate_surface(struct ivi_surface *ivi_surf,
 int
 sigchld_handler(int signal_number, void *data);
 
+void
+shell_send_app_state(struct ivi_compositor *ivi, const char *app_id,
+                    enum agl_shell_app_state state);
+
 #endif
index 96eb215..042fa55 100644 (file)
@@ -308,10 +308,7 @@ ivi_layout_activate_complete(struct ivi_output *output,
                        app_id,
                        ivi_layout_get_surface_role_name(surf), output->name);
 
-      if (wl_resource_get_version(ivi->shell_client.resource) >= AGL_SHELL_APP_STATE_SINCE_VERSION)
-               agl_shell_send_app_state(ivi->shell_client.resource,
-                                        app_id, AGL_SHELL_APP_STATE_ACTIVATED);
-
+       shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_ACTIVATED);
 }
 
 struct ivi_output *
@@ -1061,7 +1058,5 @@ ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
                weston_surface_damage(view->surface);
        }
 
-      if (wl_resource_get_version(ivi->shell_client.resource) >= AGL_SHELL_APP_STATE_SINCE_VERSION)
-             agl_shell_send_app_state(ivi->shell_client.resource, app_id,
-                                      AGL_SHELL_APP_STATE_DEACTIVATED);
+      shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_DEACTIVATED);
 }
index 9fe6cf1..f8d2e32 100644 (file)
@@ -1138,6 +1138,22 @@ insert_black_curtain(struct ivi_output *output)
        weston_log("Added black curtain to output %s\n", output->output->name);
 }
 
+void
+shell_send_app_state(struct ivi_compositor *ivi, const char *app_id,
+                    enum agl_shell_app_state state)
+{
+       if (app_id && wl_resource_get_version(ivi->shell_client.resource) >=
+           AGL_SHELL_APP_STATE_SINCE_VERSION) {
+
+               agl_shell_send_app_state(ivi->shell_client.resource,
+                                        app_id, state);
+
+               if (ivi->shell_client_ext.resource)
+                       agl_shell_send_app_state(ivi->shell_client_ext.resource,
+                                                app_id, state);
+       }
+}
+
 static void
 shell_ready(struct wl_client *client, struct wl_resource *shell_res)
 {
@@ -1176,11 +1192,7 @@ shell_ready(struct wl_client *client, struct wl_resource *shell_res)
                surface->checked_pending = true;
                app_id = weston_desktop_surface_get_app_id(surface->dsurface);
 
-               if (app_id &&
-                   wl_resource_get_version(ivi->shell_client.resource) >=
-                   AGL_SHELL_APP_STATE_SINCE_VERSION)
-                       agl_shell_send_app_state(ivi->shell_client.resource,
-                                                app_id, AGL_SHELL_APP_STATE_STARTED);
+               shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_STARTED);
        }
 }