input: Fix minor issue while reporting disable cursor
[src/agl-compositor.git] / src / shell.c
index d91570f..cbe1252 100644 (file)
 static void
 create_black_surface_view(struct ivi_output *output);
 
-static struct ivi_surface *
-get_ivi_shell_surface(struct weston_surface *wsurface)
-{
-       if (weston_surface_is_desktop_surface(wsurface)) {
-               struct weston_desktop_surface *dsurface =
-                       weston_surface_get_desktop_surface(wsurface);
-               return weston_desktop_surface_get_user_data(dsurface);
-       }
-
-       return NULL;
-}
-
 void
 agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
                                           struct ivi_surface *surface)
@@ -99,6 +87,16 @@ ivi_set_desktop_surface(struct ivi_surface *surface)
        agl_shell_desktop_advertise_application_id(ivi, surface);
 }
 
+static void
+ivi_set_background_surface(struct ivi_surface *surface)
+{
+       struct ivi_compositor *ivi = surface->ivi;
+       assert(surface->role == IVI_SURFACE_ROLE_BACKGROUND);
+
+       wl_list_insert(&surface->ivi->surfaces, &surface->link);
+       agl_shell_desktop_advertise_application_id(ivi, surface);
+}
+
 static void
 ivi_set_desktop_surface_popup(struct ivi_surface *surface)
 {
@@ -479,7 +477,7 @@ ivi_set_pending_desktop_surface_remote(struct ivi_output *ioutput,
        if (!p_remote)
                return;
 
-       wl_list_insert(&ivi->remote_pending_apps, &remote->link);
+       wl_list_insert(&ivi->remote_pending_apps, &p_remote->link);
 }
 
 
@@ -638,14 +636,9 @@ ivi_check_pending_surface_desktop(struct ivi_surface *surface,
        const char *app_id =
                weston_desktop_surface_get_app_id(surface->dsurface);
 
-       if (!app_id) {
-               *role = IVI_SURFACE_ROLE_NONE;
-               return;
-       }
-
        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)) {
+               if (app_id && !strcmp(app_id, p_popup->app_id)) {
                        *role = IVI_SURFACE_ROLE_POPUP;
                        return;
                }
@@ -653,7 +646,7 @@ ivi_check_pending_surface_desktop(struct ivi_surface *surface,
 
        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)) {
+               if (app_id && !strcmp(app_id, p_split->app_id)) {
                        *role = IVI_SURFACE_ROLE_SPLIT_V;
                        return;
                }
@@ -661,7 +654,7 @@ ivi_check_pending_surface_desktop(struct ivi_surface *surface,
 
        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)) {
+               if (app_id && !strcmp(app_id, p_fullscreen->app_id)) {
                        *role = IVI_SURFACE_ROLE_FULLSCREEN;
                        return;
                }
@@ -669,7 +662,7 @@ ivi_check_pending_surface_desktop(struct ivi_surface *surface,
 
        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)) {
+               if (app_id && !strcmp(app_id, p_remote->app_id)) {
                        *role = IVI_SURFACE_ROLE_REMOTE;
                        return;
                }
@@ -787,6 +780,8 @@ ivi_shell_destroy_views_on_layer(struct weston_layer *layer)
 void
 ivi_shell_finalize(struct ivi_compositor *ivi)
 {
+       struct ivi_output *output;
+
        ivi_shell_destroy_views_on_layer(&ivi->hidden);
        weston_layer_fini(&ivi->hidden);
 
@@ -801,6 +796,14 @@ ivi_shell_finalize(struct ivi_compositor *ivi)
 
        ivi_shell_destroy_views_on_layer(&ivi->popup);
        weston_layer_fini(&ivi->popup);
+
+       wl_list_for_each(output, &ivi->outputs, link) {
+               if (output->fullscreen_view.fs->view) {
+                       weston_surface_destroy(output->fullscreen_view.fs->view->surface);
+                       output->fullscreen_view.fs->view = NULL;
+               }
+       }
+       weston_layer_fini(&ivi->fullscreen);
 }
 
 static void
@@ -1031,8 +1034,14 @@ shell_ready(struct wl_client *client, struct wl_resource *shell_res)
        ivi->shell_client.ready = true;
 
        wl_list_for_each(output, &ivi->outputs, link) {
-               if (output->background)
+               if (output->background &&
+                   output->background->role == IVI_SURFACE_ROLE_BACKGROUND) {
+                       /* track the background surface role as a "regular"
+                        * surface so we can activate it */
+                       ivi_set_background_surface(output->background);
                        remove_black_surface(output);
+               }
+
                ivi_layout_init(ivi, output);
        }