layout: Send dimensions when setting up property as fullscreen 15/27415/3
authorMarius Vlad <marius.vlad@collabora.com>
Wed, 27 Apr 2022 12:44:58 +0000 (15:44 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Tue, 3 May 2022 06:56:40 +0000 (06:56 +0000)
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

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

index efebfc1..255b182 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 424f126..b0403c0 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 daffd5e..70cc837 100644 (file)
@@ -256,8 +256,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;
 }