weston: Add fix for using layer_entry_remove directly
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0001-libweston-Add-paint-node-destruction-into-weston_lay.patch
1 From cfde02d47a503cbfd0629bbfe0cb776686af8a91 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Tue, 9 Apr 2024 18:34:22 +0300
4 Subject: [PATCH] libweston: Add paint node destruction into
5  weston_layer_entry_remove()
6
7 This prevents a potential crash where users of
8 weston_layer_entry_insert/layer_entry_remove() would see when moving
9 views into a NULL layer (effectively unmapping the surface/view).
10
11 Users that have migrated to the weston_view_move_to_layer() are immune
12 to this issue because that takes care paint node destruction.
13
14 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
15 ---
16  libweston/compositor.c | 17 ++++++++++-------
17  1 file changed, 10 insertions(+), 7 deletions(-)
18
19 diff --git a/libweston/compositor.c b/libweston/compositor.c
20 index bb29b83b5..ea257bb90 100644
21 --- a/libweston/compositor.c
22 +++ b/libweston/compositor.c
23 @@ -3980,17 +3980,10 @@ weston_view_move_to_layer(struct weston_view *view,
24                           struct weston_layer_entry *layer)
25  {
26         bool was_mapped = view->is_mapped;
27 -       struct weston_paint_node *pnode, *pntmp;
28  
29         if (layer == &view->layer_link)
30                 return;
31  
32 -       /* Remove all paint nodes because we have no idea what a layer change
33 -        * does to view visibility on any output.
34 -        */
35 -       wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
36 -               weston_paint_node_destroy(pnode);
37 -
38         view->surface->compositor->view_list_needs_rebuild = true;
39  
40         /* Damage the view's old region, and remove it from the layer. */
41 @@ -4020,6 +4013,16 @@ weston_view_move_to_layer(struct weston_view *view,
42  WL_EXPORT void
43  weston_layer_entry_remove(struct weston_layer_entry *entry)
44  {
45 +       struct weston_paint_node *pnode, *pntmp;
46 +       struct weston_view *view;
47 +
48 +       /* Remove all paint nodes because we have no idea what a layer change
49 +        * does to view visibility on any output.
50 +        */
51 +       view = container_of(entry, struct weston_view, layer_link);
52 +       wl_list_for_each_safe(pnode, pntmp, &view->paint_node_list, view_link)
53 +               weston_paint_node_destroy(pnode);
54 +
55         wl_list_remove(&entry->link);
56         wl_list_init(&entry->link);
57         entry->layer = NULL;
58 -- 
59 2.43.0
60