layout: Allow to commit the fullscreen and split surface roles 09/24509/3
authorMarius Vlad <marius.vlad@collabora.com>
Wed, 29 Apr 2020 14:41:58 +0000 (17:41 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Mon, 18 May 2020 10:01:48 +0000 (13:01 +0300)
Now that we have the ability to discern between fullscreend and
split roles, use specific functions when doing the commit to further
customize them.

Bug-AGL: SPEC-3334

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

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

index 3624a8c..2649193 100644 (file)
@@ -117,6 +117,11 @@ desktop_surface_removed(struct weston_desktop_surface *dsurface, void *userdata)
                output = surface->desktop.last_output;
        else if (surface->role == IVI_SURFACE_ROLE_POPUP)
                output = surface->popup.output;
                output = surface->desktop.last_output;
        else if (surface->role == IVI_SURFACE_ROLE_POPUP)
                output = surface->popup.output;
+       else if (surface->role == IVI_SURFACE_ROLE_SPLIT_H ||
+                surface->role == IVI_SURFACE_ROLE_SPLIT_V)
+               output = surface->split.output;
+       else if (surface->role == IVI_SURFACE_ROLE_FS)
+               output = surface->fs.output;
        else
                return;
 
        else
                return;
 
@@ -161,6 +166,13 @@ desktop_committed(struct weston_desktop_surface *dsurface,
        case IVI_SURFACE_ROLE_POPUP:
                ivi_layout_popup_committed(surface);
                break;
        case IVI_SURFACE_ROLE_POPUP:
                ivi_layout_popup_committed(surface);
                break;
+       case IVI_SURFACE_ROLE_FS:
+               ivi_layout_fs_committed(surface);
+               break;
+       case IVI_SURFACE_ROLE_SPLIT_H:
+       case IVI_SURFACE_ROLE_SPLIT_V:
+               ivi_layout_split_committed(surface);
+               break;
        case IVI_SURFACE_ROLE_NONE:
        case IVI_SURFACE_ROLE_BACKGROUND:
        default: /* fall through */
        case IVI_SURFACE_ROLE_NONE:
        case IVI_SURFACE_ROLE_BACKGROUND:
        default: /* fall through */
index c0e41e6..7cd1253 100644 (file)
@@ -320,6 +320,12 @@ ivi_layout_panel_committed(struct ivi_surface *surface);
 void
 ivi_layout_popup_committed(struct ivi_surface *surface);
 
 void
 ivi_layout_popup_committed(struct ivi_surface *surface);
 
+void
+ivi_layout_fs_committed(struct ivi_surface *surface);
+
+void
+ivi_layout_split_committed(struct ivi_surface *surface);
+
 void
 ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id);
 
 void
 ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id);
 
index 60197b0..02bedc9 100644 (file)
@@ -284,6 +284,98 @@ skip_config_check:
        ivi_layout_activate_complete(output, surf);
 }
 
        ivi_layout_activate_complete(output, surf);
 }
 
+void
+ivi_layout_fs_committed(struct ivi_surface *surface)
+{
+       struct ivi_compositor *ivi = surface->ivi;
+
+       struct weston_desktop_surface *dsurface = surface->dsurface;
+       struct weston_surface *wsurface =
+               weston_desktop_surface_get_surface(dsurface);
+
+       struct ivi_output *output = surface->split.output;
+       struct weston_output *woutput = output->output;
+
+       struct weston_view *view = surface->view;
+       struct weston_geometry geom;
+
+       if (surface->view->is_mapped)
+               return;
+
+       geom = weston_desktop_surface_get_geometry(dsurface);
+       weston_log("(fs) geom x %d, y %d, width %d, height %d\n", geom.x, geom.y,
+                       geom.width, geom.height);
+
+       assert(surface->role == IVI_SURFACE_ROLE_FS);
+
+       weston_desktop_surface_set_fullscreen(dsurface, true);
+
+       weston_view_set_output(view, woutput);
+       weston_view_set_position(view, woutput->x, woutput->y);
+       weston_layer_entry_insert(&ivi->fullscreen.view_list, &view->layer_link);
+
+       weston_view_update_transform(view);
+       weston_view_damage_below(view);
+
+       wsurface->is_mapped = true;
+       surface->view->is_mapped = true;
+}
+
+void
+ivi_layout_split_committed(struct ivi_surface *surface)
+{
+       struct ivi_compositor *ivi = surface->ivi;
+
+       struct weston_desktop_surface *dsurface = surface->dsurface;
+       struct weston_surface *wsurface =
+               weston_desktop_surface_get_surface(dsurface);
+
+       struct ivi_output *output = surface->split.output;
+       struct weston_output *woutput = output->output;
+
+       struct weston_view *view = surface->view;
+       struct weston_geometry geom;
+       int x;
+       int y;
+
+       x = woutput->x;
+       y = woutput->y;
+
+       if (surface->view->is_mapped)
+               return;
+
+       geom = weston_desktop_surface_get_geometry(dsurface);
+       weston_log("(split) geom x %d, y %d, width %d, height %d\n", geom.x, geom.y,
+                       geom.width, geom.height);
+
+       assert(surface->role == IVI_SURFACE_ROLE_SPLIT_H ||
+              surface->role == IVI_SURFACE_ROLE_SPLIT_V);
+
+       weston_view_set_output(view, woutput);
+
+       switch (surface->role) {
+       case IVI_SURFACE_ROLE_SPLIT_V:
+               x += woutput->width - geom.width;
+               output->area.width -= geom.width;
+               break;
+       case IVI_SURFACE_ROLE_SPLIT_H:
+               output->area.y += geom.height;
+               output->area.height -= geom.height;
+               break;
+       default:
+               abort();
+       }
+
+       weston_view_set_position(view, x, y);
+       weston_layer_entry_insert(&ivi->normal.view_list, &view->layer_link);
+
+       weston_view_update_transform(view);
+       weston_view_damage_below(view);
+
+       wsurface->is_mapped = true;
+       surface->view->is_mapped = true;
+}
+
 void
 ivi_layout_popup_committed(struct ivi_surface *surface)
 {
 void
 ivi_layout_popup_committed(struct ivi_surface *surface)
 {
index f184c63..cb70691 100644 (file)
@@ -140,14 +140,22 @@ ivi_set_pending_desktop_surface_split(struct ivi_output *ioutput,
                                      const char *app_id, uint32_t orientation)
 {
        struct ivi_compositor *ivi = ioutput->ivi;
                                      const char *app_id, uint32_t orientation)
 {
        struct ivi_compositor *ivi = ioutput->ivi;
+       struct ivi_surface *surf;
        size_t len_app_id = strlen(app_id);
        size_t len_app_id = strlen(app_id);
+       struct pending_split *split;
 
        if (orientation != AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_VERTICAL &&
            orientation != AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_HORIZONTAL)
                return;
 
 
        if (orientation != AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_VERTICAL &&
            orientation != AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_HORIZONTAL)
                return;
 
-       struct pending_split *split = zalloc(sizeof(*split));
+       /* more than one is un-supported, do note we need to do
+        * conversion for surface roles instead of using the protocol ones */
+       wl_list_for_each(surf, &ivi->surfaces, link)
+               if (surf->role == IVI_SURFACE_ROLE_SPLIT_V ||
+                   surf->role == IVI_SURFACE_ROLE_SPLIT_H)
+                       return;
 
 
+       split = zalloc(sizeof(*split));
        split->app_id = zalloc(sizeof(char) * (len_app_id + 1));
        memcpy(split->app_id, app_id, len_app_id);
 
        split->app_id = zalloc(sizeof(char) * (len_app_id + 1));
        memcpy(split->app_id, app_id, len_app_id);