src/shell: Add set_app_property_mode request
[src/agl-compositor.git] / src / shell.c
index f059de6..3f528de 100644 (file)
@@ -54,6 +54,7 @@ agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
                                           struct ivi_surface *surface)
 {
        struct desktop_client *dclient;
+       static bool display_adv = false;
 
        if (surface->advertised_on_launch)
                return;
@@ -63,7 +64,10 @@ agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
                const char *app_id =
                        weston_desktop_surface_get_app_id(surface->dsurface);
                if (app_id == NULL) {
-                       weston_log("WARNING app_is is null, unable to advertise\n");
+                       if (!display_adv) {
+                               weston_log("WARNING app_is is null, unable to advertise\n");
+                               display_adv = true;
+                       }
                        return;
                }
                agl_shell_desktop_send_application(dclient->resource, app_id);
@@ -353,6 +357,12 @@ ivi_remove_pending_desktop_surface_remote(struct pending_remote *remote)
        free(remote);
 }
 
+static bool
+ivi_compositor_keep_pending_surfaces(struct ivi_surface *surface)
+{
+       return surface->ivi->keep_pending_surfaces;
+}
+
 static bool
 ivi_check_pending_desktop_surface_popup(struct ivi_surface *surface)
 {
@@ -376,7 +386,8 @@ ivi_check_pending_desktop_surface_popup(struct ivi_surface *surface)
                        surface->popup.bb.width = p_popup->bb.width;
                        surface->popup.bb.height = p_popup->bb.height;
 
-                       ivi_remove_pending_desktop_surface_popup(p_popup);
+                       if (!ivi_compositor_keep_pending_surfaces(surface))
+                               ivi_remove_pending_desktop_surface_popup(p_popup);
                        return true;
                }
        }
@@ -400,7 +411,8 @@ ivi_check_pending_desktop_surface_split(struct ivi_surface *surface)
                if (!strcmp(_app_id, split_surf->app_id)) {
                        surface->split.output = split_surf->ioutput;
                        surface->split.orientation = split_surf->orientation;
-                       ivi_remove_pending_desktop_surface_split(split_surf);
+                       if (!ivi_compositor_keep_pending_surfaces(surface))
+                               ivi_remove_pending_desktop_surface_split(split_surf);
                        return true;
                }
        }
@@ -423,7 +435,8 @@ ivi_check_pending_desktop_surface_fullscreen(struct ivi_surface *surface)
                              &ivi->fullscreen_pending_apps, link) {
                if (!strcmp(_app_id, fs_surf->app_id)) {
                        surface->fullscreen.output = fs_surf->ioutput;
-                       ivi_remove_pending_desktop_surface_fullscreen(fs_surf);
+                       if (!ivi_compositor_keep_pending_surfaces(surface))
+                               ivi_remove_pending_desktop_surface_fullscreen(fs_surf);
                        return true;
                }
        }
@@ -446,7 +459,8 @@ ivi_check_pending_desktop_surface_remote(struct ivi_surface *surface)
                              &ivi->remote_pending_apps, link) {
                if (!strcmp(_app_id, remote_surf->app_id)) {
                        surface->remote.output = remote_surf->ioutput;
-                       ivi_remove_pending_desktop_surface_remote(remote_surf);
+                       if (!ivi_compositor_keep_pending_surfaces(surface))
+                               ivi_remove_pending_desktop_surface_remote(remote_surf);
                        return true;
                }
        }
@@ -454,6 +468,53 @@ ivi_check_pending_desktop_surface_remote(struct ivi_surface *surface)
        return false;
 }
 
+bool
+ivi_check_pending_surface(struct ivi_surface *surface)
+{
+       struct ivi_compositor *ivi = surface->ivi;
+       struct wl_list *role_pending_list;
+       struct pending_popup *p_popup;
+       struct pending_split *p_split;
+       struct pending_fullscreen *p_fullscreen;
+       struct pending_remote *p_remote;
+       const char *app_id =
+               weston_desktop_surface_get_app_id(surface->dsurface);
+
+       if (!app_id)
+               return false;
+
+       role_pending_list = &ivi->popup_pending_apps;
+       wl_list_for_each(p_popup, role_pending_list, link) {
+               if (!strcmp(app_id, p_popup->app_id)) {
+                       return true;
+               }
+       }
+
+       role_pending_list = &ivi->split_pending_apps;
+       wl_list_for_each(p_split, role_pending_list, link) {
+               if (!strcmp(app_id, p_split->app_id)) {
+                       return true;
+               }
+       }
+
+       role_pending_list = &ivi->fullscreen_pending_apps;
+       wl_list_for_each(p_fullscreen, role_pending_list, link) {
+               if (!strcmp(app_id, p_fullscreen->app_id)) {
+                       return true;
+               }
+       }
+
+       role_pending_list = &ivi->remote_pending_apps;
+       wl_list_for_each(p_remote, role_pending_list, link) {
+               if (!strcmp(app_id, p_remote->app_id)) {
+                       return true;
+               }
+       }
+
+       /* else, we are a regular desktop surface */
+       return false;
+}
+
 
 void
 ivi_check_pending_desktop_surface(struct ivi_surface *surface)
@@ -707,7 +768,7 @@ remove_black_surface(struct ivi_output *output)
        weston_layer_entry_remove(&view->layer_link);
        weston_view_update_transform(view);
 
-       weston_output_damage(output->output);
+       weston_view_damage_below(view);
 }
 
 void
@@ -734,7 +795,7 @@ insert_black_surface(struct ivi_output *output)
        view->surface->is_mapped = true;
 
        weston_view_update_transform(view);
-       weston_output_damage(output->output);
+       weston_view_damage_below(view);
 }
 
 static void
@@ -1007,10 +1068,50 @@ shell_desktop_set_app_property(struct wl_client *client,
        }
 }
 
+static void
+ivi_compositor_destroy_pending_surfaces(struct ivi_compositor *ivi)
+{
+       struct pending_popup *p_popup, *next_p_popup;
+       struct pending_split *split_surf, *next_split_surf;
+       struct pending_fullscreen *fs_surf, *next_fs_surf;
+       struct pending_remote *remote_surf, *next_remote_surf;
+
+       wl_list_for_each_safe(p_popup, next_p_popup,
+                             &ivi->popup_pending_apps, link)
+               ivi_remove_pending_desktop_surface_popup(p_popup);
+
+       wl_list_for_each_safe(split_surf, next_split_surf,
+                             &ivi->split_pending_apps, link)
+               ivi_remove_pending_desktop_surface_split(split_surf);
+
+       wl_list_for_each_safe(fs_surf, next_fs_surf,
+                             &ivi->fullscreen_pending_apps, link)
+               ivi_remove_pending_desktop_surface_fullscreen(fs_surf);
+
+       wl_list_for_each_safe(remote_surf, next_remote_surf,
+                             &ivi->remote_pending_apps, link)
+               ivi_remove_pending_desktop_surface_remote(remote_surf);
+}
+
+static void
+shell_desktop_set_app_property_mode(struct wl_client *client,
+                                   struct wl_resource *shell_res, uint32_t perm)
+{
+       struct desktop_client *dclient = wl_resource_get_user_data(shell_res);
+       if (perm) {
+               dclient->ivi->keep_pending_surfaces = true;
+       } else {
+               dclient->ivi->keep_pending_surfaces = false;
+               /* remove any previous pending surfaces */
+               ivi_compositor_destroy_pending_surfaces(dclient->ivi);
+       }
+}
+
 static const struct agl_shell_desktop_interface agl_shell_desktop_implementation = {
        .activate_app = shell_desktop_activate_app,
        .set_app_property = shell_desktop_set_app_property,
        .deactivate_app = shell_deactivate_app,
+       .set_app_property_mode = shell_desktop_set_app_property_mode,
 };
 
 static void
@@ -1160,7 +1261,7 @@ ivi_shell_create_global(struct ivi_compositor *ivi)
        }
 
        ivi->agl_shell_desktop = wl_global_create(ivi->compositor->wl_display,
-                                                 &agl_shell_desktop_interface, 1,
+                                                 &agl_shell_desktop_interface, 2,
                                                  ivi, bind_agl_shell_desktop);
        if (!ivi->agl_shell_desktop) {
                weston_log("Failed to create wayland global (agl_shell_desktop).\n");