layout: Send dimensions when setting up property as fullscreen 31/27531/1
authorMarius Vlad <marius.vlad@collabora.com>
Wed, 27 Apr 2022 12:44:58 +0000 (15:44 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Thu, 26 May 2022 12:24:00 +0000 (15:24 +0300)
Instead of doing it at commit time, do it right after getting the xdg
toplevel surface such that clients can use it from the beginning.

This now includes fullscreen, besides regular desktop roles, and it
avoid mapping the fullscreen upon commit if the dimensions do not really
match up.

Bug-AGL: SPEC-4339
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I7185b10770c69d1d6572b0bc025c4a58fe431c67
(cherry picked from commit 13ac8bab43fffd002196d3a6760eefaa8944def2)

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

index 74ce916..849e272 100644 (file)
@@ -103,6 +103,36 @@ get_focused_output(struct weston_compositor *compositor)
        return output;
 }
 
+static void
+desktop_surface_added_configure(struct ivi_surface *surface,
+                               struct ivi_output *ivi_output)
+{
+       enum ivi_surface_role role = IVI_SURFACE_ROLE_NONE;
+       struct weston_desktop_surface *dsurface = surface->dsurface;
+
+       ivi_check_pending_surface_desktop(surface, &role);
+       if ((role != IVI_SURFACE_ROLE_DESKTOP &&
+            role != IVI_SURFACE_ROLE_FULLSCREEN) ||
+            role == IVI_SURFACE_ROLE_NONE)
+               return;
+
+       if (role == IVI_SURFACE_ROLE_FULLSCREEN) {
+               struct ivi_output *bg_output =
+                       ivi_layout_find_bg_output(surface->ivi);
+               assert(bg_output);
+               weston_desktop_surface_set_fullscreen(dsurface, true);
+               weston_desktop_surface_set_size(dsurface,
+                                               bg_output->output->width,
+                                               bg_output->output->height);
+               return;
+       }
+
+       weston_desktop_surface_set_maximized(dsurface, true);
+       weston_desktop_surface_set_size(dsurface,
+                                       ivi_output->area.width,
+                                       ivi_output->area.height);
+}
+
 
 static void
 desktop_surface_added(struct weston_desktop_surface *dsurface, void *userdata)
@@ -168,16 +198,7 @@ desktop_surface_added(struct weston_desktop_surface *dsurface, void *userdata)
 
        if (output && ivi->shell_client.ready) {
                struct ivi_output *ivi_output = to_ivi_output(output);
-
-               /* verify if by any chance this surfaces hasn't been assigned a
-                * different role before sending the maximized state */
-               if (!ivi_check_pending_surface(surface)) {
-                       weston_log("Setting surface to initial size of surface to %dx%d\n",
-                                       ivi_output->area.width, ivi_output->area.height);
-                       weston_desktop_surface_set_maximized(dsurface, true);
-                       weston_desktop_surface_set_size(dsurface,
-                                       ivi_output->area.width, ivi_output->area.height);
-               }
+               desktop_surface_added_configure(surface, ivi_output);
        }
        /*
         * We delay creating "normal" desktop surfaces until later, to
index e89d215..0b26d04 100644 (file)
@@ -423,9 +423,12 @@ agl_shell_desktop_advertise_application_id(struct ivi_compositor *ivi,
 void
 ivi_destroy_waltham_destroy(struct ivi_surface *surface);
 
-bool
-ivi_check_pending_surface(struct ivi_surface *surface);
+void
+ivi_check_pending_surface_desktop(struct ivi_surface *surface,
+                                 enum ivi_surface_role *role);
 
+struct ivi_output *
+ivi_layout_find_bg_output(struct ivi_compositor *ivi);
 void
 ivi_compositor_destroy_pending_surfaces(struct ivi_compositor *ivi);
 
index 0356d01..62e422c 100644 (file)
@@ -253,8 +253,7 @@ ivi_layout_find_with_app_id(const char *app_id, struct ivi_compositor *ivi)
        return NULL;
 }
 
-
-static struct ivi_output *
+struct ivi_output *
 ivi_layout_find_bg_output(struct ivi_compositor *ivi)
 {
        struct ivi_output *out;
@@ -403,6 +402,7 @@ ivi_layout_fullscreen_committed(struct ivi_surface *surface)
 
        struct ivi_output *output = surface->split.output;
        struct weston_output *woutput = output->output;
+       struct ivi_output *bg_output = ivi_layout_find_bg_output(ivi);
 
        struct weston_view *view = surface->view;
        struct weston_geometry geom;
@@ -416,12 +416,19 @@ ivi_layout_fullscreen_committed(struct ivi_surface *surface)
                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_FULLSCREEN);
 
-       weston_desktop_surface_set_fullscreen(dsurface, true);
+       if (!weston_desktop_surface_get_fullscreen(dsurface) ||
+           geom.width != bg_output->output->width ||
+           geom.height != bg_output->output->height) {
+               struct weston_desktop_client *desktop_client =
+                       weston_desktop_surface_get_client(dsurface);
+               struct wl_client *client =
+                       weston_desktop_client_get_client(desktop_client);
+               wl_client_post_implementation_error(client,
+                               "Can not display surface due to invalid geometry");
+               return;
+       }
 
        weston_view_set_output(view, woutput);
        weston_view_set_position(view, woutput->x, woutput->y);
index f874fd0..bf14302 100644 (file)
@@ -613,9 +613,9 @@ ivi_check_pending_desktop_surface_remote(struct ivi_surface *surface)
 
        return false;
 }
-
-bool
-ivi_check_pending_surface(struct ivi_surface *surface)
+void
+ivi_check_pending_surface_desktop(struct ivi_surface *surface,
+                                 enum ivi_surface_role *role)
 {
        struct ivi_compositor *ivi = surface->ivi;
        struct wl_list *role_pending_list;
@@ -626,39 +626,45 @@ ivi_check_pending_surface(struct ivi_surface *surface)
        const char *app_id =
                weston_desktop_surface_get_app_id(surface->dsurface);
 
-       if (!app_id)
-               return false;
+       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)) {
-                       return true;
+                       *role = IVI_SURFACE_ROLE_POPUP;
+                       return;
                }
        }
 
        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 = IVI_SURFACE_ROLE_SPLIT_V;
+                       return;
                }
        }
 
        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 = IVI_SURFACE_ROLE_FULLSCREEN;
+                       return;
                }
        }
 
        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;
+                       *role = IVI_SURFACE_ROLE_REMOTE;
+                       return;
                }
        }
 
        /* else, we are a regular desktop surface */
-       return false;
+       *role = IVI_SURFACE_ROLE_DESKTOP;
 }