From 62e661dc6ea3efc6496b2b0d3758aaf292579c15 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Sun, 2 May 2021 12:34:12 +0100
Subject: [PATCH 1/3] Import Debian changes 3.24.24-4

---
 debian/changelog                              |  43 ++++
 ...Fix-a-possible-crash-in-gtk_show_uri.patch |  27 ++
 ...-tablet-events-on-destroyed-surfaces.patch | 241 ++++++++++++++++++
 ...device-scale-to-the-offset-when-blur.patch |  30 +++
 ...ntchooser-Fix-some-since-annotations.patch |  44 ++++
 ...wable-Free-the-pixbuf-on-Cairo-error.patch |  23 ++
 ...ting-link-state-if-we-have-no-layout.patch |  31 +++
 ...location-even-if-mount-was-not-found.patch |  46 ++++
 .../scale-Fix-sporadic-criticals.patch        |  52 ++++
 debian/patches/series                         |  11 +
 ...updateiconcache-Sort-list-of-entries.patch |   1 +
 .../x11-Be-quiet-on-exit-by-default.patch     |  49 ++++
 ...x11-Don-t-beep-on-untrusted-displays.patch |  42 +++
 .../x11-dnd-Ignore-XErrors-from-the-COW.patch |  36 +++
 14 files changed, 676 insertions(+)
 create mode 100644 debian/patches/Fix-a-possible-crash-in-gtk_show_uri.patch
 create mode 100644 debian/patches/Wayland-ignore-touch-tablet-events-on-destroyed-surfaces.patch
 create mode 100644 debian/patches/cssshadowvalue-Apply-device-scale-to-the-offset-when-blur.patch
 create mode 100644 debian/patches/fontchooser-Fix-some-since-annotations.patch
 create mode 100644 debian/patches/gdkpixbuf-drawable-Free-the-pixbuf-on-Cairo-error.patch
 create mode 100644 debian/patches/label-Skip-updating-link-state-if-we-have-no-layout.patch
 create mode 100644 debian/patches/placesview-Open-location-even-if-mount-was-not-found.patch
 create mode 100644 debian/patches/scale-Fix-sporadic-criticals.patch
 create mode 100644 debian/patches/x11-Be-quiet-on-exit-by-default.patch
 create mode 100644 debian/patches/x11-Don-t-beep-on-untrusted-displays.patch
 create mode 100644 debian/patches/x11-dnd-Ignore-XErrors-from-the-COW.patch

diff --git a/debian/changelog b/debian/changelog
index f263c59..b5f500d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,46 @@
+gtk+3.0 (3.24.24-4) unstable; urgency=medium
+
+  * Add various patches from upstream 3.24.25 to 3.24.29, mostly
+    crash fixes:
+    - d/p/gdkpixbuf-drawable-Free-the-pixbuf-on-Cairo-error.patch:
+      Fix a memory leak when a Cairo error occurs
+    - d/p/Wayland-ignore-touch-tablet-events-on-destroyed-surfaces.patch:
+      Fix crashes if input events are received on a recently-closed window
+      or menu
+    - d/p/label-Skip-updating-link-state-if-we-have-no-layout.patch:
+      Fix crash if a GtkLabel's activate-link handler changes the
+      label's markup
+    - d/p/x11-dnd-Ignore-XErrors-from-the-COW.patch:
+      Adds a missing error trap to prevent crashes in X11 drag & drop.
+      The X11 functions called here cannot normally fail, but it seems
+      they can fail in certain configurations of the NVIDIA proprietary
+      driver. (LP: #1911036)
+    - d/p/cssshadowvalue-Apply-device-scale-to-the-offset-when-blur.patch:
+      Apply scale factor to blurred shadows.
+      In particular this makes the desktop-icons-ng GNOME Shell extension,
+      as used in Ubuntu 21.04, display correctly on HiDPI displays.
+      (LP: #1919404)
+    - d/p/scale-Fix-sporadic-criticals.patch:
+      Fix a possible crash due to use-after-free
+    - d/p/fontchooser-Fix-some-since-annotations.patch:
+      Correct documentation
+    - d/p/x11-Be-quiet-on-exit-by-default.patch:
+      Don't spam the system log when disconnected from the X11 display
+    - d/p/Fix-a-possible-crash-in-gtk_show_uri.patch:
+      Don't crash if asked to display a URI that doesn't have a useful
+      basename
+    - d/p/x11-Don-t-beep-on-untrusted-displays.patch:
+      Don't beep if connected to an X11 display that distrusts the
+      application (ssh -X -oForwardX11Trusted=no), which can result in a
+      fatal error
+    - d/p/placesview-Open-location-even-if-mount-was-not-found.patch:
+      Fix inability to display SMB server's list of shares
+      (e.g. smb://192.168.1.1/) in Nautilus
+  * d/p/updateiconcache-Sort-list-of-entries.patch:
+    Mark as applied upstream to GTK 3 as well as to GTK 4
+
+ -- Simon McVittie <smcv@debian.org>  Sun, 02 May 2021 12:34:12 +0100
+
 gtk+3.0 (3.24.24-3) unstable; urgency=medium
 
   * d/patches: Backport font settings bug fixes recommended by upstream
diff --git a/debian/patches/Fix-a-possible-crash-in-gtk_show_uri.patch b/debian/patches/Fix-a-possible-crash-in-gtk_show_uri.patch
new file mode 100644
index 0000000..78e4ca7
--- /dev/null
+++ b/debian/patches/Fix-a-possible-crash-in-gtk_show_uri.patch
@@ -0,0 +1,27 @@
+From: Matthias Clasen <mclasen@redhat.com>
+Date: Mon, 19 Apr 2021 16:39:53 -0400
+Subject: Fix a possible crash in gtk_show_uri
+
+g_file_get_basename can return NULL.
+Deal with it somehow.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/3883
+Origin: upstream, 3.24.29, commit:536da7a15c
+---
+ gdk/x11/gdkapplaunchcontext-x11.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c
+index 8051229..2341bb2 100644
+--- a/gdk/x11/gdkapplaunchcontext-x11.c
++++ b/gdk/x11/gdkapplaunchcontext-x11.c
+@@ -45,6 +45,9 @@ get_display_name (GFile     *file,
+   if (name == NULL)
+     {
+       name = g_file_get_basename (file);
++      if (name == NULL)
++        name = g_file_get_uri (file);
++
+       if (!g_utf8_validate (name, -1, NULL))
+         {
+           tmp = name;
diff --git a/debian/patches/Wayland-ignore-touch-tablet-events-on-destroyed-surfaces.patch b/debian/patches/Wayland-ignore-touch-tablet-events-on-destroyed-surfaces.patch
new file mode 100644
index 0000000..2e88cb3
--- /dev/null
+++ b/debian/patches/Wayland-ignore-touch-tablet-events-on-destroyed-surfaces.patch
@@ -0,0 +1,241 @@
+From: wisp3rwind <wisp3rwind@posteo.eu>
+Date: Wed, 11 Nov 2020 10:12:26 +0100
+Subject: Wayland: ignore touch/tablet events on destroyed surfaces
+
+When destroying a wl_surface (e.g. when a window or menu is closed), the
+surface may continue to exist in the compositor slightly longer than on
+the client side. In that case, the surface can still receive input
+events, which need to be ignored gracefully.
+In particular, this prevents segfaulting on wl_surface_get_user_data()
+in that situation.
+
+Reported in
+https://gitlab.gnome.org/GNOME/gtk/-/issues/3296
+
+The same issue for pointers/keyboards was reported in
+https://bugzilla.gnome.org/show_bug.cgi?id=693338
+
+and fixed with in
+bfd7137ffbcbd8caa531d7a47d799fefb6605a5a
+3625f17857328ae7e7aa43340f29efa56575a7b0
+a8fc099a725543649fe3aab76943c14bdcd860fc
+
+Origin: upstream, 3.24.25, commit:19a740e277d3beb4ae05f30389c0792286d3e096
+---
+ gdk/wayland/gdkdevice-wayland.c | 81 +++++++++++++++++++++++++++++++++--------
+ 1 file changed, 66 insertions(+), 15 deletions(-)
+
+diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
+index c5b273e..ff05760 100644
+--- a/gdk/wayland/gdkdevice-wayland.c
++++ b/gdk/wayland/gdkdevice-wayland.c
+@@ -2506,6 +2506,9 @@ touch_handle_down (void              *data,
+ 
+   _gdk_wayland_display_update_serial (display, serial);
+ 
++  if (!wl_surface)
++    return;
++
+   touch = gdk_wayland_seat_add_touch (seat, id, wl_surface);
+   touch->x = wl_fixed_to_double (x);
+   touch->y = wl_fixed_to_double (y);
+@@ -2541,6 +2544,9 @@ touch_handle_up (void            *data,
+   _gdk_wayland_display_update_serial (display, serial);
+ 
+   touch = gdk_wayland_seat_get_touch (seat, id);
++  if (!touch)
++    return;
++
+   event = _create_touch_event (seat, touch, GDK_TOUCH_END, time);
+ 
+   GDK_NOTE (EVENTS,
+@@ -2567,6 +2573,9 @@ touch_handle_motion (void            *data,
+   GdkEvent *event;
+ 
+   touch = gdk_wayland_seat_get_touch (seat, id);
++  if (!touch)
++    return;
++
+   touch->x = wl_fixed_to_double (x);
+   touch->y = wl_fixed_to_double (y);
+ 
+@@ -3680,19 +3689,21 @@ tablet_tool_handle_proximity_in (void                      *data,
+                                  struct zwp_tablet_tool_v2 *wp_tablet_tool,
+                                  uint32_t                   serial,
+                                  struct zwp_tablet_v2      *wp_tablet,
+-                                 struct wl_surface         *surface)
++                                 struct wl_surface         *wl_surface)
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
+   GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
+   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
+-  GdkWindow *window = wl_surface_get_user_data (surface);
++  GdkWindow *window;
+   GdkEvent *event;
+ 
+-  if (!surface)
+-      return;
++  if (!wl_surface)
++    return;
++
++  window = wl_surface_get_user_data (wl_surface);
+   if (!GDK_IS_WINDOW (window))
+-      return;
++    return;
+ 
+   tool->current_tablet = tablet;
+   tablet->current_tool = tool;
+@@ -3731,6 +3742,9 @@ tablet_tool_handle_proximity_out (void                      *data,
+   GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
+ #endif
+ 
++  if (!tablet)
++    return;
++
+   GDK_NOTE (EVENTS,
+             g_message ("proximity out, seat %p, tool %d", seat,
+                        gdk_device_tool_get_tool_type (tool->tool)));
+@@ -3787,7 +3801,7 @@ tablet_tool_handle_down (void                      *data,
+   GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
+   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
+ 
+-  if (!tablet->pointer_info.focus)
++  if (!tablet || !tablet->pointer_info.focus)
+     return;
+ 
+   _gdk_wayland_display_update_serial (display_wayland, serial);
+@@ -3804,7 +3818,7 @@ tablet_tool_handle_up (void                      *data,
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+ 
+-  if (!tablet->pointer_info.focus)
++  if (!tablet || !tablet->pointer_info.focus)
+     return;
+ 
+   tablet_create_button_event_frame (tablet, GDK_BUTTON_RELEASE, GDK_BUTTON_PRIMARY);
+@@ -3823,6 +3837,9 @@ tablet_tool_handle_motion (void                      *data,
+   GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
+   GdkEvent *event;
+ 
++  if (!tablet)
++    return;
++
+   tablet->pointer_info.surface_x = wl_fixed_to_double (sx);
+   tablet->pointer_info.surface_y = wl_fixed_to_double (sy);
+ 
+@@ -3855,7 +3872,12 @@ tablet_tool_handle_pressure (void                      *data,
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+-  gint axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
++  gint axis_index;
++
++  if (!tablet)
++    return;
++
++  axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
+ 
+   _gdk_device_translate_axis (tablet->current_device, axis_index,
+                               pressure, &tablet->axes[axis_index]);
+@@ -3872,7 +3894,12 @@ tablet_tool_handle_distance (void                      *data,
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+-  gint axis_index = tablet->axis_indices[GDK_AXIS_DISTANCE];
++  gint axis_index;
++
++  if (!tablet)
++    return;
++
++  axis_index = tablet->axis_indices[GDK_AXIS_DISTANCE];
+ 
+   _gdk_device_translate_axis (tablet->current_device, axis_index,
+                               distance, &tablet->axes[axis_index]);
+@@ -3890,8 +3917,14 @@ tablet_tool_handle_tilt (void                      *data,
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+-  gint xtilt_axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
+-  gint ytilt_axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
++  gint xtilt_axis_index;
++  gint ytilt_axis_index;
++
++  if (!tablet)
++    return;
++
++  xtilt_axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
++  ytilt_axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
+ 
+   _gdk_device_translate_axis (tablet->current_device, xtilt_axis_index,
+                               wl_fixed_to_double (xtilt),
+@@ -3918,7 +3951,7 @@ tablet_tool_handle_button (void                      *data,
+   GdkEventType evtype;
+   guint n_button;
+ 
+-  if (!tablet->pointer_info.focus)
++  if (!tablet || !tablet->pointer_info.focus)
+     return;
+ 
+   tablet->pointer_info.press_serial = serial;
+@@ -3949,7 +3982,12 @@ tablet_tool_handle_rotation (void                      *data,
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+-  gint axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
++  gint axis_index;
++
++  if (!tablet)
++    return;
++
++  axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
+ 
+   _gdk_device_translate_axis (tablet->current_device, axis_index,
+                               wl_fixed_to_double (degrees),
+@@ -3968,7 +4006,12 @@ tablet_tool_handle_slider (void                      *data,
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+-  gint axis_index = tablet->axis_indices[GDK_AXIS_SLIDER];
++  gint axis_index;
++
++  if (!tablet)
++    return;
++
++  axis_index = tablet->axis_indices[GDK_AXIS_SLIDER];
+ 
+   _gdk_device_translate_axis (tablet->current_device, axis_index,
+                               position, &tablet->axes[axis_index]);
+@@ -3986,9 +4029,12 @@ tablet_tool_handle_wheel (void                      *data,
+ {
+   GdkWaylandTabletToolData *tool = data;
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+-  GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
++  GdkWaylandSeat *seat;
+   GdkEvent *event;
+ 
++  if (!tablet)
++    return;
++
+   GDK_NOTE (EVENTS,
+             g_message ("tablet tool %d wheel %d/%d",
+                        gdk_device_tool_get_tool_type (tool->tool), degrees, clicks));
+@@ -3996,6 +4042,8 @@ tablet_tool_handle_wheel (void                      *data,
+   if (clicks == 0)
+     return;
+ 
++  seat = GDK_WAYLAND_SEAT (tablet->seat);
++
+   /* Send smooth event */
+   event = create_scroll_event (seat, &tablet->pointer_info,
+                                tablet->master, tablet->current_device, FALSE);
+@@ -4021,6 +4069,9 @@ tablet_tool_handle_frame (void                      *data,
+   GdkWaylandTabletData *tablet = tool->current_tablet;
+   GdkEvent *frame_event;
+ 
++  if (!tablet)
++    return;
++
+   GDK_NOTE (EVENTS,
+             g_message ("tablet frame, time %d", time));
+ 
diff --git a/debian/patches/cssshadowvalue-Apply-device-scale-to-the-offset-when-blur.patch b/debian/patches/cssshadowvalue-Apply-device-scale-to-the-offset-when-blur.patch
new file mode 100644
index 0000000..e064448
--- /dev/null
+++ b/debian/patches/cssshadowvalue-Apply-device-scale-to-the-offset-when-blur.patch
@@ -0,0 +1,30 @@
+From: Daniel van Vugt <daniel.van.vugt@canonical.com>
+Date: Wed, 24 Mar 2021 18:28:25 +0800
+Subject: cssshadowvalue: Apply device scale to the offset when blurring text
+
+Although the surface already has the device scale set, that doesn't
+apply to the offset which is in raw device units. So we need to scale
+the device offset explicitly.
+
+Bug: https://gitlab.com/rastersoft/desktop-icons-ng/-/issues/119
+Origin: upstream, 3.24.28, commit:86da4e0c97ec037cd80edc783c7804268a0d2fc8
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gnome-shell-extension-desktop-icons-ng/+bug/1919404
+---
+ gtk/gtkcssshadowvalue.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
+index 864bdef..3c0d977 100644
+--- a/gtk/gtkcssshadowvalue.c
++++ b/gtk/gtkcssshadowvalue.c
+@@ -485,7 +485,9 @@ make_blurred_pango_surface (cairo_t           *existing_cr,
+                                                 x_scale * (ink_rect.width + 2 * clip_radius),
+                                                 y_scale * (ink_rect.height + 2 * clip_radius));
+   cairo_surface_set_device_scale (surface, x_scale, y_scale);
+-  cairo_surface_set_device_offset (surface, -ink_rect.x + clip_radius, -ink_rect.y + clip_radius);
++  cairo_surface_set_device_offset (surface,
++                                   x_scale * (-ink_rect.x + clip_radius),
++                                   y_scale * (-ink_rect.y + clip_radius));
+   cr = cairo_create (surface);
+   cairo_move_to (cr, 0, 0);
+   _gtk_pango_fill_layout (cr, layout);
diff --git a/debian/patches/fontchooser-Fix-some-since-annotations.patch b/debian/patches/fontchooser-Fix-some-since-annotations.patch
new file mode 100644
index 0000000..9e8bfeb
--- /dev/null
+++ b/debian/patches/fontchooser-Fix-some-since-annotations.patch
@@ -0,0 +1,44 @@
+From: Matthias Clasen <mclasen@redhat.com>
+Date: Sun, 11 Apr 2021 23:22:46 -0400
+Subject: fontchooser: Fix some since annotations
+
+The "level", "font-features" and "language" were annotated
+with the wrong version.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/1830
+Origin: upstream, 3.24.29, commit:3fb5890e695243916773b7b7b0891caf25958fb3
+---
+ gtk/gtkfontchooser.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/gtk/gtkfontchooser.c b/gtk/gtkfontchooser.c
+index 16df10b..576bc2e 100644
+--- a/gtk/gtkfontchooser.c
++++ b/gtk/gtkfontchooser.c
+@@ -110,7 +110,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
+    *
+    * The level of granularity to offer for selecting fonts.
+    *
+-   * Since: 3.22.30
++   * Since: 3.24.1
+    */
+   g_object_interface_install_property
+      (iface,
+@@ -129,7 +129,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
+    * The selected font features, in a format that is compatible with
+    * CSS and with Pango attributes.
+    *
+-   * Since: 3.22.30
++   * Since: 3.24.1
+    */
+   g_object_interface_install_property
+      (iface,
+@@ -146,7 +146,7 @@ gtk_font_chooser_default_init (GtkFontChooserInterface *iface)
+    * selected, in a format that is compatible with CSS and with Pango
+    * attributes.
+    *
+-   * Since: 3.22.30
++   * Since: 3.24.1
+    */
+   g_object_interface_install_property
+      (iface,
diff --git a/debian/patches/gdkpixbuf-drawable-Free-the-pixbuf-on-Cairo-error.patch b/debian/patches/gdkpixbuf-drawable-Free-the-pixbuf-on-Cairo-error.patch
new file mode 100644
index 0000000..34dacfb
--- /dev/null
+++ b/debian/patches/gdkpixbuf-drawable-Free-the-pixbuf-on-Cairo-error.patch
@@ -0,0 +1,23 @@
+From: Adrien Plazas <kekun.plazas@laposte.net>
+Date: Mon, 14 Dec 2020 13:39:42 +0100
+Subject: gdkpixbuf-drawable: Free the pixbuf on Cairo error
+
+This avoids leaking the pixbuf.
+
+Origin: upstream, 3.24.25, commit:c4f8eb7ec998f1200a5e662e00bad04acf0eb0ea
+---
+ gdk/gdkpixbuf-drawable.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c
+index d2c142a..603c8ff 100644
+--- a/gdk/gdkpixbuf-drawable.c
++++ b/gdk/gdkpixbuf-drawable.c
+@@ -288,6 +288,7 @@ gdk_pixbuf_get_from_surface  (cairo_surface_t *surface,
+   if (cairo_surface_status (surface) || dest == NULL)
+     {
+       cairo_surface_destroy (surface);
++      g_clear_object (&dest);
+       return NULL;
+     }
+ 
diff --git a/debian/patches/label-Skip-updating-link-state-if-we-have-no-layout.patch b/debian/patches/label-Skip-updating-link-state-if-we-have-no-layout.patch
new file mode 100644
index 0000000..d91266d
--- /dev/null
+++ b/debian/patches/label-Skip-updating-link-state-if-we-have-no-layout.patch
@@ -0,0 +1,31 @@
+From: =?utf-8?q?Timm_B=C3=A4der?= <mail@baedert.org>
+Date: Fri, 11 Jan 2019 17:46:12 +0100
+Subject: label: Skip updating link state if we have no layout
+
+This can happen whenever the ::activate-link handler sets different
+markup on the label, causing all links to be recreated. In this case,
+the GtkLabelLink* passed to emit_activate_link is garbage after the
+g_signal_emit call and we shouldn't try to do anything with it.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/1498
+Origin: upstream, 3.24.27, commit:bfe0f7dd4dbc37048e111caafdd9b5f555bd8d16
+---
+ gtk/gtklabel.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
+index 1a2453f..4bb92fd 100644
+--- a/gtk/gtklabel.c
++++ b/gtk/gtklabel.c
+@@ -6755,6 +6755,11 @@ emit_activate_link (GtkLabel     *label,
+   GtkStateFlags state;
+ 
+   g_signal_emit (label, signals[ACTIVATE_LINK], 0, link->uri, &handled);
++
++  /* signal handler might have invalidated the layout */
++  if (!priv->layout)
++    return;
++
+   if (handled && priv->track_links && !link->visited &&
+       priv->select_info && priv->select_info->links)
+     {
diff --git a/debian/patches/placesview-Open-location-even-if-mount-was-not-found.patch b/debian/patches/placesview-Open-location-even-if-mount-was-not-found.patch
new file mode 100644
index 0000000..f103afa
--- /dev/null
+++ b/debian/patches/placesview-Open-location-even-if-mount-was-not-found.patch
@@ -0,0 +1,46 @@
+From: Ondrej Holy <oholy@redhat.com>
+Date: Tue, 13 Apr 2021 15:55:19 +0200
+Subject: placesview: Open location even if mount was not found
+
+Some locations have to be mounted, but their mounts are not user-visible
+(e.g. smb-browse). Though this is maybe a bit weird, it is how it works
+for years. The problem is that the commit 267ea755, which tries to get the
+default location for opening, caused regression as it doesn't expect such
+possibility. Before this commit, such locations were opened without any
+issue, but nothing happens currently after clicking to "Connect" except of
+clearing the "Connect to Server" entry. Let's fallback to the original
+location if the mount was not found to fix this regression.
+
+Bug: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1811
+Origin: upstream, 3.24.29, commit:4fe7b3ec25a1a82e0682963a26bbe642072b4fa0
+---
+ gtk/gtkplacesview.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
+index 62eb5d09..89f7ace 100644
+--- a/gtk/gtkplacesview.c
++++ b/gtk/gtkplacesview.c
+@@ -1267,6 +1267,11 @@ server_mount_ready_cb (GObject      *source_file,
+           GMount *mount;
+           GFile *root;
+ 
++          /*
++           * If the mount is not found at this point, it is probably user-
++           * invisible, which happens e.g for smb-browse, but the location
++           * should be opened anyway...
++           */
+           mount = g_file_find_enclosing_mount (location, priv->cancellable, NULL);
+           if (mount)
+             {
+@@ -1277,6 +1282,10 @@ server_mount_ready_cb (GObject      *source_file,
+               g_object_unref (root);
+               g_object_unref (mount);
+             }
++          else
++            {
++              emit_open_location (view, location, priv->open_flags);
++            }
+         }
+     }
+ 
diff --git a/debian/patches/scale-Fix-sporadic-criticals.patch b/debian/patches/scale-Fix-sporadic-criticals.patch
new file mode 100644
index 0000000..011bb41
--- /dev/null
+++ b/debian/patches/scale-Fix-sporadic-criticals.patch
@@ -0,0 +1,52 @@
+From: Matthias Clasen <mclasen@redhat.com>
+Date: Sat, 10 Apr 2021 10:07:55 -0400
+Subject: scale: Fix sporadic criticals
+
+gtk_css_node_update_layout_attributes can cause us to
+free priv->layout, and then bad things happen. Therefore,
+we must call that function on a new layout *before* setting
+priv->layout.
+
+Origin: upstream, 3.24.29, commit:eaabc3722eb65b726da3ff1184061b7a66499740
+---
+ gtk/gtkscale.c | 17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
+index ea30a8c..529fb3d 100644
+--- a/gtk/gtkscale.c
++++ b/gtk/gtkscale.c
+@@ -2020,23 +2020,26 @@ gtk_scale_get_layout (GtkScale *scale)
+ 
+   if (!priv->layout && priv->draw_value)
+     {
++      PangoLayout *layout;
+       int min_layout_width;
+ 
+-      priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
+-      gtk_css_node_update_layout_attributes (gtk_css_gadget_get_node (priv->value_gadget), priv->layout);
+-
++      layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
++      gtk_css_node_update_layout_attributes (gtk_css_gadget_get_node (priv->value_gadget), layout);
+       gtk_css_gadget_get_preferred_size (priv->value_gadget,
+                                          GTK_ORIENTATION_HORIZONTAL, -1,
+                                          &min_layout_width, NULL,
+                                          NULL, NULL);
+-      pango_layout_set_width (priv->layout, min_layout_width * PANGO_SCALE);
++
++      pango_layout_set_width (layout, min_layout_width * PANGO_SCALE);
+ 
+       if (priv->value_pos == GTK_POS_LEFT)
+-        pango_layout_set_alignment (priv->layout, PANGO_ALIGN_RIGHT);
++        pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
+       else if (priv->value_pos == GTK_POS_RIGHT)
+-        pango_layout_set_alignment (priv->layout, PANGO_ALIGN_LEFT);
++        pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
+       else
+-        pango_layout_set_alignment (priv->layout, PANGO_ALIGN_CENTER);
++        pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
++
++      priv->layout = layout;
+     }
+ 
+   if (priv->draw_value)
diff --git a/debian/patches/series b/debian/patches/series
index 4ad0500..d9cfb53 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,6 +1,17 @@
+gdkpixbuf-drawable-Free-the-pixbuf-on-Cairo-error.patch
+Wayland-ignore-touch-tablet-events-on-destroyed-surfaces.patch
 gdk-wayland-Mark-matched-settings-from-the-portal-as-vali.patch
 gdk-wayland-Look-for-font-settings-recursively.patch
+label-Skip-updating-link-state-if-we-have-no-layout.patch
 updateiconcache-Sort-list-of-entries.patch
+x11-dnd-Ignore-XErrors-from-the-COW.patch
+cssshadowvalue-Apply-device-scale-to-the-offset-when-blur.patch
+scale-Fix-sporadic-criticals.patch
+fontchooser-Fix-some-since-annotations.patch
+x11-Be-quiet-on-exit-by-default.patch
+Fix-a-possible-crash-in-gtk_show_uri.patch
+x11-Don-t-beep-on-untrusted-displays.patch
+placesview-Open-location-even-if-mount-was-not-found.patch
 gdk-Don-t-distribute-generated-files-in-tarballs.patch
 gtk-Really-don-t-distribute-built-files.patch
 demos-examples-tests-Don-t-distribute-built-files.patch
diff --git a/debian/patches/updateiconcache-Sort-list-of-entries.patch b/debian/patches/updateiconcache-Sort-list-of-entries.patch
index 6855aa2..66dd2d6 100644
--- a/debian/patches/updateiconcache-Sort-list-of-entries.patch
+++ b/debian/patches/updateiconcache-Sort-list-of-entries.patch
@@ -9,6 +9,7 @@ had variations between builds in /usr/share/balsa/icon-theme.cache
 
 Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/297
 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=953105
+Applied-upstream: 3.24.28, commit:850768270f86f060ad317933b629593f6fdd08be
 Applied-upstream: 3.96.0, commit:b364827a5b99e3b02862f36be4c03826e72aefba
 ---
  gtk/updateiconcache.c | 9 +++++++++
diff --git a/debian/patches/x11-Be-quiet-on-exit-by-default.patch b/debian/patches/x11-Be-quiet-on-exit-by-default.patch
new file mode 100644
index 0000000..d946bfc
--- /dev/null
+++ b/debian/patches/x11-Be-quiet-on-exit-by-default.patch
@@ -0,0 +1,49 @@
+From: Matthias Clasen <mclasen@redhat.com>
+Date: Tue, 13 Apr 2021 14:10:27 -0400
+Subject: x11: Be quiet on exit by default
+
+The condition we check for to catch X servers going away
+may not be accurate anymore, and the warning shows up in
+logs, causing customers to be concerned. So, be quiet by
+default, unless the user explicitly asked for a message.
+
+Origin: upstream, 3.24.29, commit:c3503fcc84eec0bcf857cc744580aa9a4d5dc7eb
+---
+ gdk/x11/gdkmain-x11.c | 23 ++++++-----------------
+ 1 file changed, 6 insertions(+), 17 deletions(-)
+
+diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
+index 64c7cb4..cd877ce 100644
+--- a/gdk/x11/gdkmain-x11.c
++++ b/gdk/x11/gdkmain-x11.c
+@@ -240,24 +240,13 @@ gdk_x_io_error (Display *display)
+   /* This is basically modelled after the code in XLib. We need
+    * an explicit error handler here, so we can disable our atexit()
+    * which would otherwise cause a nice segfault.
+-   * We fprintf(stderr, instead of g_warning() because g_warning()
+-   * could possibly be redirected to a dialog
++   * We g_debug() instead of g_warning(), because g_warning()
++   * could possibly be redirected to the log
+    */
+-  if (errno == EPIPE)
+-    {
+-      g_message ("The application '%s' lost its connection to the display %s;\n"
+-                 "most likely the X server was shut down or you killed/destroyed\n"
+-                 "the application.\n",
+-                 g_get_prgname (),
+-                 display ? DisplayString (display) : gdk_get_display_arg_name ());
+-    }
+-  else
+-    {
+-      g_message ("%s: Fatal IO error %d (%s) on X server %s.\n",
+-                 g_get_prgname (),
+-                 errno, g_strerror (errno),
+-                 display ? DisplayString (display) : gdk_get_display_arg_name ());
+-    }
++  g_debug ("%s: Fatal IO error %d (%s) on X server %s.\n",
++           g_get_prgname (),
++           errno, g_strerror (errno),
++           display ? DisplayString (display) : gdk_get_display_arg_name ());
+ 
+   _exit (1);
+ }
diff --git a/debian/patches/x11-Don-t-beep-on-untrusted-displays.patch b/debian/patches/x11-Don-t-beep-on-untrusted-displays.patch
new file mode 100644
index 0000000..f1f86e5
--- /dev/null
+++ b/debian/patches/x11-Don-t-beep-on-untrusted-displays.patch
@@ -0,0 +1,42 @@
+From: Matthias Clasen <mclasen@redhat.com>
+Date: Tue, 20 Apr 2021 20:55:21 -0400
+Subject: x11: Don't beep on untrusted displays
+
+This can trigger BadAccess, and we don't
+want that.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/3862
+Origin: upstream, 3.24.29, commit:9c84f7645e487558cf44e5489d0face8cac3314d
+---
+ gdk/x11/gdkdisplay-x11.c | 3 +++
+ gdk/x11/gdkwindow-x11.c  | 3 +++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
+index 817944e..7e08f47 100644
+--- a/gdk/x11/gdkdisplay-x11.c
++++ b/gdk/x11/gdkdisplay-x11.c
+@@ -1964,6 +1964,9 @@ _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
+ static void
+ gdk_x11_display_beep (GdkDisplay *display)
+ {
++  if (!GDK_X11_DISPLAY (display)->trusted_client)
++    return;
++
+ #ifdef HAVE_XKB
+   XkbBell (GDK_DISPLAY_XDISPLAY (display), None, 0, None);
+ #else
+diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
+index 38ff91d..721d9bb 100644
+--- a/gdk/x11/gdkwindow-x11.c
++++ b/gdk/x11/gdkwindow-x11.c
+@@ -5472,6 +5472,9 @@ gdk_x11_window_beep (GdkWindow *window)
+ 
+   display = GDK_WINDOW_DISPLAY (window);
+ 
++  if (!GDK_X11_DISPLAY (display)->trusted_client)
++    return FALSE;
++
+ #ifdef HAVE_XKB
+   if (GDK_X11_DISPLAY (display)->use_xkb)
+     {
diff --git a/debian/patches/x11-dnd-Ignore-XErrors-from-the-COW.patch b/debian/patches/x11-dnd-Ignore-XErrors-from-the-COW.patch
new file mode 100644
index 0000000..750b969
--- /dev/null
+++ b/debian/patches/x11-dnd-Ignore-XErrors-from-the-COW.patch
@@ -0,0 +1,36 @@
+From: Olivier Fourdan <ofourdan@redhat.com>
+Date: Mon, 22 Mar 2021 15:19:33 +0100
+Subject: x11/dnd: Ignore XErrors from the COW
+
+The DnD code for X11 adds the composite overlay window (aka COW) to the
+cache.
+
+Yet the X11 requests to get and release the COW may trigger XErrors that
+we ought to ignore otherwise the client will abort.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/3715
+Bug-Ubuntu: https://launchpad.net/bugs/1911036
+Origin: upstream, 3.24.28, commit:39db78470452cf0b1a7d1ee196de3f20eea85d33
+---
+ gdk/x11/gdkdnd-x11.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
+index e07fa10..113d0a8 100644
+--- a/gdk/x11/gdkdnd-x11.c
++++ b/gdk/x11/gdkdnd-x11.c
+@@ -634,12 +634,14 @@ gdk_window_cache_new (GdkScreen *screen)
+    */
+   if (gdk_screen_is_composited (screen))
+     {
++      gdk_x11_display_error_trap_push (GDK_X11_SCREEN (screen)->display);
+       cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
+       gdk_window_cache_add (result, cow, 0, 0, 
+ 			    gdk_x11_screen_get_width (screen) * GDK_X11_SCREEN(screen)->window_scale, 
+ 			    gdk_x11_screen_get_height (screen) * GDK_X11_SCREEN(screen)->window_scale, 
+ 			    TRUE);
+       XCompositeReleaseOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
++      gdk_x11_display_error_trap_pop_ignored (GDK_X11_SCREEN (screen)->display);
+     }
+ #endif
+ 
-- 
GitLab


From 13d05aa48da136c7741272af0480973da2f09b9b Mon Sep 17 00:00:00 2001
From: Ritesh Raj Sarraf <ritesh.sarraf@collabora.com>
Date: Mon, 19 Jul 2021 21:31:44 +0530
Subject: [PATCH 2/3] Release gtk+3.0 version 3.24.24-4+apertis1

Signed-off-by: Ritesh Raj Sarraf <ritesh.sarraf@collabora.com>
---
 debian/changelog | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 37f28d3..b10b86d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+gtk+3.0 (3.24.24-4+apertis1) apertis; urgency=medium
+
+  * Sync updates from Debian Bullseye
+
+ -- Apertis CI <devel@lists.apertis.org>  Mon, 19 Jul 2021 15:51:42 +0000
+
 gtk+3.0 (3.24.24-4) unstable; urgency=medium
 
   * Add various patches from upstream 3.24.25 to 3.24.29, mostly
-- 
GitLab


From 171bcbaa7d3111b3be4c4c146987526be04c7240 Mon Sep 17 00:00:00 2001
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Thu, 5 Aug 2021 12:32:54 +0000
Subject: [PATCH 3/3] Refresh the automatically detected licensing information

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
---
 debian/apertis/copyright | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/debian/apertis/copyright b/debian/apertis/copyright
index 42d8030..cf74c5f 100644
--- a/debian/apertis/copyright
+++ b/debian/apertis/copyright
@@ -96,7 +96,7 @@ Copyright: no-info-found
 License: LGPL-2.1
 
 Files: docs/reference/Makefile.in
-Copyright: 1994-2018, Free Software Foundation, Inc.
+Copyright: 1991, 1994-2018, Free Software Foundation, Inc.
 License: LGPL-2.1
 
 Files: docs/reference/gdk/Makefile.in
@@ -111,12 +111,22 @@ Files: docs/reference/gtk/gtk3-sections.txt
 Copyright: gtk_about_dialog_set_copyright
 License: LGPL-2.1
 
+Files: docs/reference/gtk/html/gtk-resources.html
+ docs/reference/gtk/html/gtk.html
+Copyright: no-info-found
+License: LGPL
+
+Files: docs/reference/gtk/overview.xml
+ docs/reference/gtk/resources.sgml
+Copyright: no-info-found
+License: LGPL
+
 Files: docs/reference/libgail-util/Makefile.in
 Copyright: 1994-2018, Free Software Foundation, Inc.
 License: GPL-3+
 
 Files: gdk/*
-Copyright: 1991, 1999, Free Software Foundation, Inc.
+Copyright: 1991, 1994-2018, Free Software Foundation, Inc.
 License: LGPL-2.1
 
 Files: gdk/broadway/*
-- 
GitLab