[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1004575: bullseye-pu: package mutter/3.38.6-2~deb11u2



Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian.org@packages.debian.org
Usertags: pu

[ Reason ]
Bug fix updates from upstream gnome-3-38 branch, prompted by user request
in #1002651.

[ Impact ]
The first few patches resolve crashes (of either Firefox or the whole
desktop) with newer Firefox versions in Wayland mode, which might be
installed via Flatpak or future bullseye updates. I have not reproduced
these myself, but they seem to be the main reason for the user request.

d/p/surface-actor-Fix-unobscurred_fraction-calculation.patch fixes
incorrect refresh rates in multi-monitor setups; upstream asked me to
get this into Debian 11 "for multimedia folks".

d/p/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch
avoids a flood of X11 events which can cause performance problems for
Xwayland apps.

The last few patches fix visual glitches when Wayland clients use certain
protocols; I was able to reproduce this with GStreamer waylandsink, which
draws video frames incorrectly when its window is resized.

[ Tests ]
mutter has autopkgtests, which pass.

The updated version resolves the waylandsink issue and seems to work OK
in general on Intel hardware. I'll put it through some more manual testing
on Intel/Mesa/Wayland and NVIDIA/proprietary/Xorg before uploading.

[ Risks ]
It's a key package and part of our default desktop environment, but
upstream are generally conservative about backporting bug fixes to stable
branches. These fixes have all been in unstable for a while.

I can drop some of these changes if the release team would prefer to only
take a subset of them.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
All changes are patches against upstream source, see d/changelog for
how they fit together in batches.
diffstat for mutter-3.38.6 mutter-3.38.6

 changelog                                                               |   30 +
 patches/series                                                          |    9 
 patches/surface-actor-Fix-unobscurred_fraction-calculation.patch        |   29 +
 patches/wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch |   45 ++
 patches/wayland-subsurface-Check-for-parent-actor-before-unparent.patch |   29 +
 patches/wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch |   62 +++
 patches/wayland-surface-Do-not-uncoditionally-process-surface-dam.patch |  163 ++++++++++
 patches/wayland-surface-Switch-order-for-calculating-surface-dama.patch |   64 +++
 patches/wayland-surface-Use-correct-default-viewport-for-surface-.patch |   53 +++
 patches/window-actor-wayland-Remove-subsurface-actors-on-dispose.patch  |   66 ++++
 patches/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch |   33 ++
 11 files changed, 583 insertions(+)

diff -Nru mutter-3.38.6/debian/changelog mutter-3.38.6/debian/changelog
--- mutter-3.38.6/debian/changelog	2021-09-01 21:25:34.000000000 +0100
+++ mutter-3.38.6/debian/changelog	2022-01-30 16:58:45.000000000 +0000
@@ -1,3 +1,33 @@
+mutter (3.38.6-2~deb11u2) bullseye; urgency=medium
+
+  * d/patches: Update to commit 3.38.6-9-g0b26ad635 from gnome-3-38 branch
+    (Closes: #1002651)
+    - d/p/wayland-subsurface-Check-for-parent-actor-before-unparent.patch,
+      d/p/wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch,
+      d/p/window-actor-wayland-Remove-subsurface-actors-on-dispose.patch:
+      Fix a crash involving Wayland subsurfaces, which can be triggered by
+      Firefox in Wayland mode (fix backported from 41~beta and 40.5)
+    - d/p/wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch:
+      Fix protocol error during Alt + drag-and-drop from Firefox in
+      Wayland mode, which would result in Firefox being terminated
+      (fix backported from 41.1 and 40.6)
+    - d/p/surface-actor-Fix-unobscurred_fraction-calculation.patch:
+      When an app/game using VSync is full-screen in a multi-monitor setup,
+      use the refresh rate of the correct monitor (LP: #1788535)
+      (fix backported from 41.3)
+    - d/p/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch:
+      Avoid flooding Xwayland clients (X11 apps under Wayland) with window
+      management events, which can cause performance problems
+      (fix backported from 41.1 and 40.6)
+    - d/p/wayland-surface-Switch-order-for-calculating-surface-dama.patch,
+      d/p/wayland-surface-Use-correct-default-viewport-for-surface-.patch,
+      d/p/wayland-surface-Do-not-uncoditionally-process-surface-dam.patch:
+      Fix visible glitches for Wayland clients that use the wp_viewporter
+      protocol in combination with wl_surface_damage(), such as the
+      GStreamer waylandsink element (fix backported from 41.3)
+
+ -- Simon McVittie <smcv@debian.org>  Sun, 30 Jan 2022 16:58:45 +0000
+
 mutter (3.38.6-2~deb11u1) bullseye; urgency=medium
 
   * Rebuild for bullseye
diff -Nru mutter-3.38.6/debian/patches/series mutter-3.38.6/debian/patches/series
--- mutter-3.38.6/debian/patches/series	2021-09-01 21:25:34.000000000 +0100
+++ mutter-3.38.6/debian/patches/series	2022-01-30 16:58:45.000000000 +0000
@@ -1,3 +1,12 @@
+wayland-subsurface-Check-for-parent-actor-before-unparent.patch
+wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch
+window-actor-wayland-Remove-subsurface-actors-on-dispose.patch
+xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch
+wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch
+surface-actor-Fix-unobscurred_fraction-calculation.patch
+wayland-surface-Switch-order-for-calculating-surface-dama.patch
+wayland-surface-Use-correct-default-viewport-for-surface-.patch
+wayland-surface-Do-not-uncoditionally-process-surface-dam.patch
 monitor-manager-Don-t-include-generated-code-in-header-fi.patch
 theme-use-gtk_render_icon_suface-to-paint-button-icon.patch
 theme-load-icons-as-Gtk-does-with-fallback-and-RTL-suppor.patch
diff -Nru mutter-3.38.6/debian/patches/surface-actor-Fix-unobscurred_fraction-calculation.patch mutter-3.38.6/debian/patches/surface-actor-Fix-unobscurred_fraction-calculation.patch
--- mutter-3.38.6/debian/patches/surface-actor-Fix-unobscurred_fraction-calculation.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/surface-actor-Fix-unobscurred_fraction-calculation.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,29 @@
+From: Robert Mader <robert.mader@posteo.de>
+Date: Sun, 19 Dec 2021 23:42:57 +0100
+Subject: surface-actor: Fix unobscurred_fraction calculation
+
+This calculation wrongly applied a `x2 - x1` pattern.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2169>
+
+(cherry picked from commit 6204769fdb8a048ee23f49be0ca532f8ff1d557a)
+
+Bug: https://gitlab.gnome.org/GNOME/mutter/-/issues/1971
+Origin: upstream, 3.38.7, commit:15ac84da2da518850e9c247b81d23becad223195
+---
+ src/compositor/meta-surface-actor.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
+index bdf4272..75622f6 100644
+--- a/src/compositor/meta-surface-actor.c
++++ b/src/compositor/meta-surface-actor.c
+@@ -523,7 +523,7 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
+           cairo_rectangle_int_t rect;
+ 
+           cairo_region_get_rectangle (intersection_region, i, &rect);
+-          intersection_size += (rect.width - rect.x) * (rect.height - rect.x);
++          intersection_size += rect.width * rect.height;
+         }
+       cairo_region_destroy (intersection_region);
+ 
diff -Nru mutter-3.38.6/debian/patches/wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch mutter-3.38.6/debian/patches/wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch
--- mutter-3.38.6/debian/patches/wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/wayland-data-offer-Accept-final-preferrence-of-drop-desti.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,45 @@
+From: Robert Mader <robert.mader@posteo.de>
+Date: Wed, 6 Oct 2021 20:08:12 +0200
+Subject: wayland/data-offer: Accept final preferrence of drop destination
+
+Quoting the spec for `wl_data_device::drop`:
+> If the resulting action is "ask", the action will not be considered
+> final. The drag-and-drop destination is expected to perform one last
+> wl_data_offer.set_actions request, or wl_data_offer.destroy in order
+> to cancel the operation.
+
+We did not respect the action choosen by the drop destination when
+it called `wl_data_offer::set_actions` after `wl_data_device::drop`
+if a user override was still active. This eventually resulted in
+a protocol error in `wl_data_offer::finish`, as the current action
+could still be `ask`.
+
+Fix this by only allowing a user override to `ask` before `drop` is
+called, thus making sure the final `set_actions` preference is
+honored.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2043>
+
+(cherry picked from commit 33b834c43373b715219d1b911813b59b2d0e2477)
+
+Bug: https://gitlab.gnome.org/GNOME/mutter/-/issues/1952
+Origin: upstream, 3.38.7, commit:5a6b3c4b67f2c07d4497e955f4a85a1a11474ca1
+---
+ src/wayland/meta-wayland-data-offer.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/wayland/meta-wayland-data-offer.c b/src/wayland/meta-wayland-data-offer.c
+index fa14fae..e9a7369 100644
+--- a/src/wayland/meta-wayland-data-offer.c
++++ b/src/wayland/meta-wayland-data-offer.c
+@@ -276,7 +276,9 @@ data_offer_choose_action (MetaWaylandDataOffer *offer)
+     return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
+ 
+   /* If the user is forcing an action, go for it */
+-  if ((user_action & available_actions) != 0)
++  if ((user_action & available_actions) != 0 &&
++      !(user_action == WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK &&
++        meta_wayland_data_source_get_drop_performed (source)))
+     return user_action;
+ 
+   /* If the dest side has a preferred DnD action, use it */
diff -Nru mutter-3.38.6/debian/patches/wayland-subsurface-Check-for-parent-actor-before-unparent.patch mutter-3.38.6/debian/patches/wayland-subsurface-Check-for-parent-actor-before-unparent.patch
--- mutter-3.38.6/debian/patches/wayland-subsurface-Check-for-parent-actor-before-unparent.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/wayland-subsurface-Check-for-parent-actor-before-unparent.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,29 @@
+From: Robert Mader <robert.mader@posteo.de>
+Date: Fri, 6 Aug 2021 13:12:26 +0200
+Subject: wayland/subsurface: Check for parent actor before unparenting
+
+No need to assume the actor still has a parent. This silences warnings
+in normal builds and prevents a crash in fully optimized ones.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
+
+Bug: https://gitlab.gnome.org/GNOME/mutter/-/issues/1892
+Origin: upstream, 3.38.7, commit:0db4ac7373965011a0fb2d3ff0465c227333d4c3
+---
+ src/wayland/meta-wayland-subsurface.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c
+index e876277..e8842a7 100644
+--- a/src/wayland/meta-wayland-subsurface.c
++++ b/src/wayland/meta-wayland-subsurface.c
+@@ -291,7 +291,8 @@ unparent_actor (MetaWaylandSurface *surface)
+     return;
+ 
+   parent_actor = clutter_actor_get_parent (actor);
+-  clutter_actor_remove_child (parent_actor, actor);
++  if (parent_actor)
++    clutter_actor_remove_child (parent_actor, actor);
+ }
+ 
+ static void
diff -Nru mutter-3.38.6/debian/patches/wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch mutter-3.38.6/debian/patches/wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch
--- mutter-3.38.6/debian/patches/wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/wayland-subsurface-Handle-node-unlinking-on-parent-destro.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,62 @@
+From: Robert Mader <robert.mader@posteo.de>
+Date: Fri, 6 Aug 2021 13:10:52 +0200
+Subject: wayland/subsurface: Handle node unlinking on parent destroyed
+
+It concerns subsurface state and the subsurface already listenes
+for the parent to get destroyed.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
+
+Bug: https://gitlab.gnome.org/GNOME/mutter/-/issues/1892
+Origin: upstream, 3.38.7, commit:60afd63ef581b11b7cd8483d4a83ce24480ed8e8
+---
+ src/wayland/meta-wayland-subsurface.c |  1 +
+ src/wayland/meta-wayland-surface.c    | 16 +---------------
+ 2 files changed, 2 insertions(+), 15 deletions(-)
+
+diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c
+index e8842a7..6b21b23 100644
+--- a/src/wayland/meta-wayland-subsurface.c
++++ b/src/wayland/meta-wayland-subsurface.c
+@@ -490,6 +490,7 @@ surface_handle_parent_surface_destroyed (struct wl_listener *listener,
+                                                  surface,
+                                                  sub.parent_destroy_listener);
+ 
++  g_node_unlink (surface->subsurface_branch_node);
+   surface->sub.parent = NULL;
+ }
+ 
+diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
+index 6f9af85..403da52 100644
+--- a/src/wayland/meta-wayland-surface.c
++++ b/src/wayland/meta-wayland-surface.c
+@@ -1363,13 +1363,6 @@ meta_wayland_surface_notify_unmapped (MetaWaylandSurface *surface)
+   g_signal_emit (surface, surface_signals[SURFACE_UNMAPPED], 0);
+ }
+ 
+-static void
+-unlink_note (GNode    *node,
+-             gpointer  data)
+-{
+-  g_node_unlink (node);
+-}
+-
+ static void
+ wl_surface_destructor (struct wl_resource *resource)
+ {
+@@ -1418,14 +1411,7 @@ wl_surface_destructor (struct wl_resource *resource)
+   if (surface->wl_subsurface)
+     wl_resource_destroy (surface->wl_subsurface);
+ 
+-  if (surface->subsurface_branch_node)
+-    {
+-      g_node_children_foreach (surface->subsurface_branch_node,
+-                               G_TRAVERSE_NON_LEAVES,
+-                               unlink_note,
+-                               NULL);
+-      g_clear_pointer (&surface->subsurface_branch_node, g_node_destroy);
+-    }
++  g_clear_pointer (&surface->subsurface_branch_node, g_node_destroy);
+ 
+   g_hash_table_destroy (surface->shortcut_inhibited_seats);
+ 
diff -Nru mutter-3.38.6/debian/patches/wayland-surface-Do-not-uncoditionally-process-surface-dam.patch mutter-3.38.6/debian/patches/wayland-surface-Do-not-uncoditionally-process-surface-dam.patch
--- mutter-3.38.6/debian/patches/wayland-surface-Do-not-uncoditionally-process-surface-dam.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/wayland-surface-Do-not-uncoditionally-process-surface-dam.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,163 @@
+From: Robert Mader <robert.mader@collabora.com>
+Date: Sat, 18 Dec 2021 22:00:41 +0100
+Subject: wayland/surface: Do not uncoditionally process surface damage
+
+Most clients nowadays switched to buffer damage, most notably Mesa
+and Xwayland. Thus lets avoid the extra cost of allocating three
+`cairo_region_t`s and doing some calculations.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
+
+(cherry picked from commit c498ae337f57a67c6e678d549cf9a8070c32f251)
+
+Origin: upstream, 3.38.7, commit:0b26ad635e703dc5cd1255933253c4dd40d611d5
+---
+ src/wayland/meta-wayland-surface.c | 111 +++++++++++++++++++------------------
+ 1 file changed, 58 insertions(+), 53 deletions(-)
+
+diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
+index 6459989..ea649da 100644
+--- a/src/wayland/meta-wayland-surface.c
++++ b/src/wayland/meta-wayland-surface.c
+@@ -324,12 +324,7 @@ surface_process_damage (MetaWaylandSurface *surface,
+                         cairo_region_t     *buffer_region)
+ {
+   MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
+-  cairo_rectangle_int_t surface_rect;
+   cairo_rectangle_int_t buffer_rect;
+-  cairo_region_t *scaled_region;
+-  cairo_region_t *transformed_region;
+-  cairo_region_t *viewport_region;
+-  graphene_rect_t src_rect;
+   MetaSurfaceActor *actor;
+ 
+   /* If the client destroyed the buffer it attached before committing, but
+@@ -344,59 +339,73 @@ surface_process_damage (MetaWaylandSurface *surface,
+     .height = get_buffer_height (surface),
+   };
+ 
+-  /* Intersect the damage region with the surface region before scaling in
+-   * order to avoid integer overflow when scaling a damage region is too large
+-   * (for example INT32_MAX which mesa passes). */
+-  surface_rect = (cairo_rectangle_int_t) {
+-    .width = meta_wayland_surface_get_width (surface),
+-    .height = meta_wayland_surface_get_height (surface),
+-  };
+-  cairo_region_intersect_rectangle (surface_region, &surface_rect);
+-
+-  /* The damage region must be in the same coordinate space as the buffer,
+-   * i.e. scaled with surface->scale. */
+-  if (surface->viewport.has_src_rect)
++  if (!cairo_region_is_empty (surface_region))
+     {
+-      src_rect = (graphene_rect_t) {
+-        .origin.x = surface->viewport.src_rect.origin.x,
+-        .origin.y = surface->viewport.src_rect.origin.y,
+-        .size.width = surface->viewport.src_rect.size.width,
+-        .size.height = surface->viewport.src_rect.size.height
++      cairo_rectangle_int_t surface_rect;
++      cairo_region_t *scaled_region;
++      cairo_region_t *transformed_region;
++      cairo_region_t *viewport_region;
++      graphene_rect_t src_rect;
++
++      /* Intersect the damage region with the surface region before scaling in
++       * order to avoid integer overflow when scaling a damage region is too
++       * large (for example INT32_MAX which mesa passes). */
++      surface_rect = (cairo_rectangle_int_t) {
++        .width = meta_wayland_surface_get_width (surface),
++        .height = meta_wayland_surface_get_height (surface),
+       };
+-    }
+-  else
+-    {
+-      int width, height;
++      cairo_region_intersect_rectangle (surface_region, &surface_rect);
+ 
+-      if (meta_monitor_transform_is_rotated (surface->buffer_transform))
++      /* The damage region must be in the same coordinate space as the buffer,
++       * i.e. scaled with surface->scale. */
++      if (surface->viewport.has_src_rect)
+         {
+-          width = get_buffer_height (surface);
+-          height = get_buffer_width (surface);
++          src_rect = (graphene_rect_t) {
++            .origin.x = surface->viewport.src_rect.origin.x,
++            .origin.y = surface->viewport.src_rect.origin.y,
++            .size.width = surface->viewport.src_rect.size.width,
++            .size.height = surface->viewport.src_rect.size.height
++          };
+         }
+       else
+         {
+-          width = get_buffer_width (surface);
+-          height = get_buffer_height (surface);
+-        }
++          int width, height;
+ 
+-      src_rect = (graphene_rect_t) {
+-        .size.width = width / surface->scale,
+-        .size.height = height / surface->scale
+-      };
++          if (meta_monitor_transform_is_rotated (surface->buffer_transform))
++            {
++              width = get_buffer_height (surface);
++              height = get_buffer_width (surface);
++            }
++          else
++            {
++              width = get_buffer_width (surface);
++              height = get_buffer_height (surface);
++            }
++
++          src_rect = (graphene_rect_t) {
++            .size.width = width / surface->scale,
++            .size.height = height / surface->scale
++          };
++        }
++      viewport_region = meta_region_crop_and_scale (surface_region,
++                                                    &src_rect,
++                                                    surface_rect.width,
++                                                    surface_rect.height);
++      scaled_region = meta_region_scale (viewport_region, surface->scale);
++      transformed_region = meta_region_transform (scaled_region,
++                                                  surface->buffer_transform,
++                                                  buffer_rect.width,
++                                                  buffer_rect.height);
++
++      /* Now add the scaled, cropped and transformed damage region to the
++       * buffer damage. Buffer damage is already in the correct coordinate
++       * space. */
++      cairo_region_union (buffer_region, transformed_region);
++
++      cairo_region_destroy (viewport_region);
++      cairo_region_destroy (scaled_region);
++      cairo_region_destroy (transformed_region);
+     }
+-  viewport_region = meta_region_crop_and_scale (surface_region,
+-                                                &src_rect,
+-                                                surface_rect.width,
+-                                                surface_rect.height);
+-  scaled_region = meta_region_scale (viewport_region, surface->scale);
+-  transformed_region = meta_region_transform (scaled_region,
+-                                              surface->buffer_transform,
+-                                              buffer_rect.width,
+-                                              buffer_rect.height);
+-
+-  /* Now add the scaled, cropped and transformed damage region to the
+-   * buffer damage. Buffer damage is already in the correct coordinate space. */
+-  cairo_region_union (buffer_region, transformed_region);
+ 
+   cairo_region_intersect_rectangle (buffer_region, &buffer_rect);
+ 
+@@ -418,10 +427,6 @@ surface_process_damage (MetaWaylandSurface *surface,
+                                              rect.width, rect.height);
+         }
+     }
+-
+-  cairo_region_destroy (viewport_region);
+-  cairo_region_destroy (scaled_region);
+-  cairo_region_destroy (transformed_region);
+ }
+ 
+ MetaWaylandBuffer *
diff -Nru mutter-3.38.6/debian/patches/wayland-surface-Switch-order-for-calculating-surface-dama.patch mutter-3.38.6/debian/patches/wayland-surface-Switch-order-for-calculating-surface-dama.patch
--- mutter-3.38.6/debian/patches/wayland-surface-Switch-order-for-calculating-surface-dama.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/wayland-surface-Switch-order-for-calculating-surface-dama.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,64 @@
+From: Robert Mader <robert.mader@collabora.com>
+Date: Sat, 18 Dec 2021 18:38:21 +0100
+Subject: wayland/surface: Switch order for calculating surface damage
+
+Process surface damage in the right order, simplifying the
+calculations.
+
+No functional change intended.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
+
+(cherry picked from commit f4717d0ac51625d271f3a8cdc6804fa9461bc927)
+
+Origin: upstream, 3.38.7, commit:a9e60badaf5e0ef98a3669298b278cc9a3cb9dfc
+---
+ src/wayland/meta-wayland-surface.c | 24 +++++++++++-------------
+ 1 file changed, 11 insertions(+), 13 deletions(-)
+
+diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
+index 403da52..e3efbba 100644
+--- a/src/wayland/meta-wayland-surface.c
++++ b/src/wayland/meta-wayland-surface.c
+@@ -355,30 +355,28 @@ surface_process_damage (MetaWaylandSurface *surface,
+ 
+   /* The damage region must be in the same coordinate space as the buffer,
+    * i.e. scaled with surface->scale. */
+-  scaled_region = meta_region_scale (surface_region, surface->scale);
+   if (surface->viewport.has_src_rect)
+     {
+       src_rect = (graphene_rect_t) {
+-        .origin.x = surface->viewport.src_rect.origin.x * surface->scale,
+-        .origin.y = surface->viewport.src_rect.origin.y * surface->scale,
+-        .size.width = surface->viewport.src_rect.size.width * surface->scale,
+-        .size.height = surface->viewport.src_rect.size.height * surface->scale
++        .origin.x = surface->viewport.src_rect.origin.x,
++        .origin.y = surface->viewport.src_rect.origin.y,
++        .size.width = surface->viewport.src_rect.size.width,
++        .size.height = surface->viewport.src_rect.size.height
+       };
+     }
+   else
+     {
+       src_rect = (graphene_rect_t) {
+-        .size.width = surface_rect.width * surface->scale,
+-        .size.height = surface_rect.height * surface->scale,
++        .size.width = surface_rect.width,
++        .size.height = surface_rect.height
+       };
+     }
+-  viewport_region = meta_region_crop_and_scale (scaled_region,
++  viewport_region = meta_region_crop_and_scale (surface_region,
+                                                 &src_rect,
+-                                                surface_rect.width *
+-                                                surface->scale,
+-                                                surface_rect.height *
+-                                                surface->scale);
+-  transformed_region = meta_region_transform (viewport_region,
++                                                surface_rect.width,
++                                                surface_rect.height);
++  scaled_region = meta_region_scale (viewport_region, surface->scale);
++  transformed_region = meta_region_transform (scaled_region,
+                                               surface->buffer_transform,
+                                               buffer_rect.width,
+                                               buffer_rect.height);
diff -Nru mutter-3.38.6/debian/patches/wayland-surface-Use-correct-default-viewport-for-surface-.patch mutter-3.38.6/debian/patches/wayland-surface-Use-correct-default-viewport-for-surface-.patch
--- mutter-3.38.6/debian/patches/wayland-surface-Use-correct-default-viewport-for-surface-.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/wayland-surface-Use-correct-default-viewport-for-surface-.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,53 @@
+From: Robert Mader <robert.mader@collabora.com>
+Date: Sat, 18 Dec 2021 21:45:52 +0100
+Subject: wayland/surface: Use correct default viewport for surface damage
+
+If no viewport is set, the neutral viewport is the surface size
+without viewport destination size applied - i.e. transform and
+scale applied to the buffer size. Change it accordingly, giving
+us the same values we'd return in `get_width` in this case.
+
+As result, this only changes cases where a viewport destination
+size but no viewport source rectangle is set.
+
+The change fixes exactly such cases, e.g. the Gstreamer Wayland
+sink. Can be tested with: `gst-play-1.0 --videosink=waylandsink`.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
+
+(cherry picked from commit c1668116959664f04e509130e76a18d55429ca65)
+
+Origin: upstream, 3.38.7, commit:aeda2cbcd86e7f41e451c487f6d3ddadc3860c4a
+---
+ src/wayland/meta-wayland-surface.c | 17 +++++++++++++++--
+ 1 file changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
+index e3efbba..6459989 100644
+--- a/src/wayland/meta-wayland-surface.c
++++ b/src/wayland/meta-wayland-surface.c
+@@ -366,9 +366,22 @@ surface_process_damage (MetaWaylandSurface *surface,
+     }
+   else
+     {
++      int width, height;
++
++      if (meta_monitor_transform_is_rotated (surface->buffer_transform))
++        {
++          width = get_buffer_height (surface);
++          height = get_buffer_width (surface);
++        }
++      else
++        {
++          width = get_buffer_width (surface);
++          height = get_buffer_height (surface);
++        }
++
+       src_rect = (graphene_rect_t) {
+-        .size.width = surface_rect.width,
+-        .size.height = surface_rect.height
++        .size.width = width / surface->scale,
++        .size.height = height / surface->scale
+       };
+     }
+   viewport_region = meta_region_crop_and_scale (surface_region,
diff -Nru mutter-3.38.6/debian/patches/window-actor-wayland-Remove-subsurface-actors-on-dispose.patch mutter-3.38.6/debian/patches/window-actor-wayland-Remove-subsurface-actors-on-dispose.patch
--- mutter-3.38.6/debian/patches/window-actor-wayland-Remove-subsurface-actors-on-dispose.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/window-actor-wayland-Remove-subsurface-actors-on-dispose.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,66 @@
+From: Robert Mader <robert.mader@posteo.de>
+Date: Fri, 6 Aug 2021 13:09:04 +0200
+Subject: window-actor/wayland: Remove subsurface actors on dispose
+
+Destroying the window actor also destroys all its children. Subsurfaces
+however may get reused. If the client did not unparent them before
+the window actor got destroyed, they will be left without actor
+which results in a crash.
+
+Unparent all actors of subsurfaces on dispose to avoid that.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
+
+Bug: https://gitlab.gnome.org/GNOME/mutter/-/issues/1892
+Origin: upstream, 3.38.7, commit:58343f43dfee81a7b2791a37c610b5e27557fd6f
+---
+ src/compositor/meta-window-actor-wayland.c | 25 +++++++++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+diff --git a/src/compositor/meta-window-actor-wayland.c b/src/compositor/meta-window-actor-wayland.c
+index b1fe616..641c924 100644
+--- a/src/compositor/meta-window-actor-wayland.c
++++ b/src/compositor/meta-window-actor-wayland.c
+@@ -149,10 +149,33 @@ meta_window_actor_wayland_can_freeze_commits (MetaWindowActor *actor)
+   return FALSE;
+ }
+ 
++static void
++meta_window_actor_wayland_dispose (GObject *object)
++{
++  MetaWindowActor *window_actor = META_WINDOW_ACTOR (object);
++  MetaSurfaceActor *surface_actor =
++    meta_window_actor_get_surface (window_actor);
++  GList *children;
++  GList *l;
++
++  children = clutter_actor_get_children (CLUTTER_ACTOR (window_actor));
++  for (l = children; l; l = l->next)
++    {
++      ClutterActor *child_actor = l->data;
++
++      if (META_IS_SURFACE_ACTOR_WAYLAND (child_actor) &&
++          child_actor != CLUTTER_ACTOR (surface_actor))
++        clutter_actor_remove_child (CLUTTER_ACTOR (window_actor), child_actor);
++    }
++
++  G_OBJECT_CLASS (meta_window_actor_wayland_parent_class)->dispose (object);
++}
++
+ static void
+ meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
+ {
+   MetaWindowActorClass *window_actor_class = META_WINDOW_ACTOR_CLASS (klass);
++  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ 
+   window_actor_class->assign_surface_actor = meta_window_actor_wayland_assign_surface_actor;
+   window_actor_class->frame_complete = meta_window_actor_wayland_frame_complete;
+@@ -163,6 +186,8 @@ meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
+   window_actor_class->set_frozen = meta_window_actor_wayland_set_frozen;
+   window_actor_class->update_regions = meta_window_actor_wayland_update_regions;
+   window_actor_class->can_freeze_commits = meta_window_actor_wayland_can_freeze_commits;
++
++  object_class->dispose = meta_window_actor_wayland_dispose;
+ }
+ 
+ static void
diff -Nru mutter-3.38.6/debian/patches/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch mutter-3.38.6/debian/patches/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch
--- mutter-3.38.6/debian/patches/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch	1970-01-01 01:00:00.000000000 +0100
+++ mutter-3.38.6/debian/patches/xwayland-Fix-condition-for-queuing-a-window-to-META_QUEUE.patch	2022-01-30 16:58:45.000000000 +0000
@@ -0,0 +1,33 @@
+From: Dor Askayo <dor.askayo@gmail.com>
+Date: Fri, 1 Oct 2021 23:40:53 +0300
+Subject: xwayland: Fix condition for queuing a window to
+ META_QUEUE_CALC_SHOWING
+
+This logic was changed by accident in df642eb15. The change caused every
+Xwayland window to be queued to META_QUEUE_CALC_SHOWING on every surface
+commit. As a result, X11 window management events, including _NET_WM_STATE,
+were dispatched at clients on every single frame.
+
+Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2032>
+
+(cherry picked from commit 98d5aa159e0eb9f433b211044ce30cd612d42734)
+
+Bug: https://gitlab.gnome.org/GNOME/mutter/-/issues/1955
+Origin: upstream, 3.38.7, commit:bb85f21d1f0c7ff7d65fc4a89f41c9fed6025f05
+---
+ src/wayland/meta-xwayland-surface.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/wayland/meta-xwayland-surface.c b/src/wayland/meta-xwayland-surface.c
+index 11f5801..f86d7d4 100644
+--- a/src/wayland/meta-xwayland-surface.c
++++ b/src/wayland/meta-xwayland-surface.c
+@@ -166,7 +166,7 @@ meta_xwayland_surface_pre_apply_state (MetaWaylandSurfaceRole  *surface_role,
+   MetaXwaylandSurface *xwayland_surface = META_XWAYLAND_SURFACE (surface_role);
+ 
+   if (pending->newly_attached &&
+-      surface->buffer_ref->buffer &&
++      !surface->buffer_ref->buffer &&
+       xwayland_surface->window)
+     meta_window_queue (xwayland_surface->window, META_QUEUE_CALC_SHOWING);
+ }

Reply to: