layout: Add missing hooks for other surface roles
[src/agl-compositor.git] / src / layout.c
index 0b8858d..8879862 100644 (file)
@@ -236,8 +236,8 @@ ivi_layout_activate_complete(struct ivi_output *output,
                        ivi_layout_get_surface_role_name(surf), output->name);
 }
 
-static struct ivi_output *
-ivi_layout_find_app_id(const char *app_id, struct ivi_compositor *ivi)
+struct ivi_output *
+ivi_layout_find_with_app_id(const char *app_id, struct ivi_compositor *ivi)
 {
        struct ivi_output *out;
 
@@ -303,7 +303,7 @@ ivi_layout_desktop_committed(struct ivi_surface *surf)
                        return;
 
                /* check first if there aren't any outputs being set */
-               r_output = ivi_layout_find_app_id(app_id, surf->ivi);
+               r_output = ivi_layout_find_with_app_id(app_id, surf->ivi);
 
                if (r_output) {
                        struct weston_view *view = r_output->fullscreen_view.fs->view;
@@ -366,6 +366,7 @@ void
 ivi_layout_fullscreen_committed(struct ivi_surface *surface)
 {
        struct ivi_compositor *ivi = surface->ivi;
+       struct ivi_policy *policy = ivi->policy;
 
        struct weston_desktop_surface *dsurface = surface->dsurface;
        struct weston_surface *wsurface =
@@ -377,6 +378,10 @@ ivi_layout_fullscreen_committed(struct ivi_surface *surface)
        struct weston_view *view = surface->view;
        struct weston_geometry geom;
 
+       if (policy && policy->api.surface_activate_by_default &&
+           !policy->api.surface_activate_by_default(surface, surface->ivi))
+               return;
+
        if (surface->view->is_mapped)
                return;
 
@@ -423,6 +428,7 @@ void
 ivi_layout_split_committed(struct ivi_surface *surface)
 {
        struct ivi_compositor *ivi = surface->ivi;
+       struct ivi_policy *policy = ivi->policy;
 
        struct weston_desktop_surface *dsurface = surface->dsurface;
        struct weston_surface *wsurface =
@@ -440,6 +446,10 @@ ivi_layout_split_committed(struct ivi_surface *surface)
        x = woutput->x;
        y = woutput->y;
 
+       if (policy && policy->api.surface_activate_by_default &&
+           !policy->api.surface_activate_by_default(surface, surface->ivi))
+               return;
+
        if (surface->view->is_mapped)
                return;
 
@@ -508,6 +518,7 @@ void
 ivi_layout_popup_committed(struct ivi_surface *surface)
 {
        struct ivi_compositor *ivi = surface->ivi;
+       struct ivi_policy *policy = ivi->policy;
 
        struct weston_desktop_surface *dsurface = surface->dsurface;
        struct weston_surface *wsurface =
@@ -517,22 +528,26 @@ ivi_layout_popup_committed(struct ivi_surface *surface)
        struct weston_output *woutput = output->output;
 
        struct weston_view *view = surface->view;
-       struct weston_geometry geom;
 
-       if (surface->view->is_mapped)
+       if (policy && policy->api.surface_activate_by_default &&
+           !policy->api.surface_activate_by_default(surface, surface->ivi))
                return;
 
-       geom = weston_desktop_surface_get_geometry(dsurface);
-       weston_log("(popup) geom x %d, y %d, width %d, height %d\n", geom.x, geom.y,
-                       geom.width, geom.height);
+       if (surface->view->is_mapped)
+               return;
 
        assert(surface->role == IVI_SURFACE_ROLE_POPUP);
 
        weston_view_set_output(view, woutput);
-       if (surface->popup.x || surface->popup.y)
-               weston_view_set_position(view, surface->popup.x, surface->popup.y);
-       else
-               weston_view_set_position(view, geom.x, geom.y);
+       weston_view_set_position(view, surface->popup.x, surface->popup.y);
+
+       /* only clip the pop-up dialog window if we have a valid
+        * width and height being passed on. Users might not want to have one
+        * set-up so only enfore it is really passed on. */
+       if (surface->popup.bb.width > 0 && surface->popup.bb.height > 0)
+               weston_view_set_mask(view, surface->popup.bb.x, surface->popup.bb.y,
+                                    surface->popup.bb.width, surface->popup.bb.height);
+
        weston_layer_entry_insert(&ivi->popup.view_list, &view->layer_link);
 
        weston_view_update_transform(view);
@@ -614,6 +629,16 @@ ivi_layout_activate(struct ivi_output *output, const char *app_id)
            ivi_layout_surface_is_split_or_fullscreen(surf))
                return;
 
+       if (surf->role == IVI_SURFACE_ROLE_REMOTE) {
+               struct ivi_output *remote_output =
+                       ivi_layout_find_with_app_id(app_id, ivi);
+
+               /* if already active on a remote output do not
+                * attempt to activate it again */
+               if (remote_output && remote_output->active == surf)
+                       return;
+       }
+
 
        dsurf = surf->dsurface;
        view = surf->view;