compositor: Add option to disable black curtains
[src/agl-compositor.git] / src / shell.c
index a6c8a5b..b107fa2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019, 2022 Collabora, Ltd.
+ * Copyright © 2019, 2022, 2024 Collabora, Ltd.
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -46,9 +46,6 @@
 #include "agl-shell-server-protocol.h"
 #include "agl-shell-desktop-server-protocol.h"
 
-static void
-create_black_curtain_view(struct ivi_output *output);
-
 static uint32_t
 reverse_orientation(uint32_t orientation);
 
@@ -143,9 +140,11 @@ ivi_set_desktop_surface_remote(struct ivi_surface *surface)
        /* if thew black surface view is mapped on the mean we need
         * to remove it in order to start showing the 'remote' surface
         * just being added */
-       view = output->fullscreen_view.fs->view;
-       if (view->is_mapped || view->surface->is_mapped)
-               remove_black_curtain(output);
+       if (output->fullscreen_view.fs) {
+               view = output->fullscreen_view.fs->view;
+               if (view->is_mapped || view->surface->is_mapped)
+                       remove_black_curtain(output);
+       }
 
        wl_list_insert(&ivi->surfaces, &surface->link);
 }
@@ -1034,8 +1033,7 @@ curtain_surface_committed(struct weston_surface *es, struct weston_coord_surface
 
 }
 
-
-static void
+void
 create_black_curtain_view(struct ivi_output *output)
 {
        struct weston_surface *surface = NULL;
@@ -1103,6 +1101,7 @@ void
 remove_black_curtain(struct ivi_output *output)
 {
        struct weston_view *view;
+       struct weston_surface *wsurface;
 
        if ((!output &&
            !output->fullscreen_view.fs &&
@@ -1113,17 +1112,13 @@ remove_black_curtain(struct ivi_output *output)
        }
 
        view = output->fullscreen_view.fs->view;
+       wsurface = view->surface;
        assert(view->is_mapped == true ||
               view->surface->is_mapped == true);
 
-       view->is_mapped = false;
-       view->surface->is_mapped = false;
-
-       weston_layer_entry_remove(&view->layer_link);
-       weston_view_update_transform(view);
-
-       weston_view_damage_below(view);
+       weston_surface_unmap(wsurface);
 
+       weston_view_move_to_layer(view, NULL);
        weston_log("Removed black curtain from output %s\n", output->output->name);
 }
 
@@ -1131,6 +1126,7 @@ void
 insert_black_curtain(struct ivi_output *output)
 {
        struct weston_view *view;
+       struct weston_surface *wsurface;
 
        if ((!output &&
            !output->fullscreen_view.fs &&
@@ -1141,19 +1137,12 @@ insert_black_curtain(struct ivi_output *output)
        }
 
        view = output->fullscreen_view.fs->view;
+       wsurface = view->surface;
        if (view->is_mapped || view->surface->is_mapped)
                return;
 
-       weston_layer_entry_remove(&view->layer_link);
-       weston_layer_entry_insert(&output->ivi->fullscreen.view_list,
-                                 &view->layer_link);
-
-       view->is_mapped = true;
-       view->surface->is_mapped = true;
-
-       weston_view_update_transform(view);
-       weston_view_damage_below(view);
-
+       weston_surface_map(wsurface);
+       weston_view_move_to_layer(view, &output->ivi->fullscreen.view_list);
        weston_log("Added black curtain to output %s\n", output->output->name);
 }
 
@@ -1866,6 +1855,7 @@ _ivi_set_shell_surface_split(struct ivi_surface *surface, struct ivi_output *iou
        struct weston_view *ev = surface->view;
        struct weston_geometry geom = {};
        struct ivi_output *output = NULL;
+       struct weston_coord_global pos;
 
        int new_width, new_height;
        int x, y;
@@ -1970,7 +1960,10 @@ _ivi_set_shell_surface_split(struct ivi_surface *surface, struct ivi_output *iou
                        ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE);
        }
 
-       weston_view_set_position(surface->view, x, y);
+       pos.c.x = x;
+       pos.c.y = y;
+
+       weston_view_set_position(surface->view, pos);
        weston_desktop_surface_set_size(surface->dsurface, new_width, new_height);
        weston_desktop_surface_set_orientation(surface->dsurface, orientation);
        surface->orientation = orientation;