shell: Advertise app when app_id is available 08/25408/3
authorWalter Lozano <walter.lozano@collabora.com>
Wed, 23 Sep 2020 13:31:23 +0000 (13:31 +0000)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Thu, 15 Oct 2020 09:33:47 +0000 (09:33 +0000)
When using GTK-3 to create apps, the framework issues set_parent_id
which forces a surface to be added even before the app_id is set.
This causes the compositor to fail to advertise the app.

This patch tries to overcome this issue by checking on surface commit
if the surface was previously advertised, and do it if it was not.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
Change-Id: I4e5fec82c1008c30d8ae7d213d85a82e39c404c3

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

index 58d2887..87ba7e1 100644 (file)
@@ -42,6 +42,16 @@ get_default_output(struct weston_compositor *compositor)
 }
 #endif
 
+static void
+desktop_advertise_app(struct wl_listener *listener, void *data)
+{
+       struct ivi_surface *surface;
+
+       surface = wl_container_of(listener, surface, listener_advertise_app);
+
+       agl_shell_desktop_advertise_application_id(surface->ivi, surface);
+}
+
 static void
 desktop_ping_timeout(struct weston_desktop_client *dclient, void *userdata)
 {
@@ -84,6 +94,13 @@ desktop_surface_added(struct weston_desktop_surface *dsurface, void *userdata)
        surface->dsurface = dsurface;
        surface->role = IVI_SURFACE_ROLE_NONE;
        surface->activated_by_default = false;
+       surface->advertised_on_launch = false;
+
+       wl_signal_init(&surface->signal_advertise_app);
+
+       surface->listener_advertise_app.notify = desktop_advertise_app;
+       wl_signal_add(&surface->signal_advertise_app,
+                     &surface->listener_advertise_app);
 
        weston_desktop_surface_set_user_data(dsurface, surface);
 
@@ -141,6 +158,9 @@ desktop_surface_removed(struct weston_desktop_surface *dsurface, void *userdata)
 
        struct ivi_output *output = ivi_layout_get_output_from_surface(surface);
 
+       wl_list_remove(&surface->listener_advertise_app.link);
+       surface->listener_advertise_app.notify = NULL;
+
        /* special corner-case, pending_surfaces which are never activated or
         * being assigned an output might land here so just remove the surface;
         *
@@ -237,6 +257,9 @@ desktop_committed(struct weston_desktop_surface *dsurface,
            !policy->api.surface_commited(surface, surface->ivi))
                return;
 
+       if (!surface->advertised_on_launch)
+               wl_signal_emit(&surface->signal_advertise_app, surface);
+
        weston_compositor_schedule_repaint(surface->ivi->compositor);
 
        switch (surface->role) {
index 4708b5d..0c9d604 100644 (file)
@@ -243,6 +243,7 @@ struct ivi_surface {
                int32_t width, height;
        } pending;
        bool activated_by_default;
+       bool advertised_on_launch;
 
        enum ivi_surface_role role;
        union {
@@ -254,6 +255,9 @@ struct ivi_surface {
                struct ivi_split_surface split;
                struct ivi_remote_surface remote;
        };
+
+       struct wl_listener listener_advertise_app;
+       struct wl_signal signal_advertise_app;
 };
 
 struct ivi_shell_client {
@@ -389,4 +393,7 @@ ivi_seat_init(struct ivi_compositor *ivi);
 void
 ivi_seat_reset_caps_sent(struct ivi_compositor *ivi);
 
+void
+agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
+                                          struct ivi_surface *surface);
 #endif
index 2cefcd6..e85d788 100644 (file)
@@ -1392,7 +1392,6 @@ int main(int argc, char *argv[])
        wl_list_init(&ivi.remote_pending_apps);
        wl_list_init(&ivi.desktop_clients);
 
-
        /* Prevent any clients we spawn getting our stdin */
        os_fd_set_cloexec(STDIN_FILENO);
 
index 94fdb66..e6fb332 100644 (file)
 static void
 create_black_surface_view(struct ivi_output *output);
 
-static void
+void
 agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
                                           struct ivi_surface *surface)
 {
        struct desktop_client *dclient;
 
+       if (surface->advertised_on_launch)
+               return;
+
        /* advertise to all desktop clients the new surface */
        wl_list_for_each(dclient, &ivi->desktop_clients, link) {
                const char *app_id =
@@ -60,6 +63,7 @@ agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
                        return;
                }
                agl_shell_desktop_send_application(dclient->resource, app_id);
+               surface->advertised_on_launch = true;
        }
 }