Add more patches from upstream, 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/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
This commit is contained in:
Simon McVittie 2021-05-02 12:34:05 +01:00
parent f283273197
commit d58741af41
10 changed files with 564 additions and 0 deletions

View File

@ -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;

View File

@ -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));

View File

@ -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,

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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);
+ }
}
}

View File

@ -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)

View File

@ -1,8 +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

View File

@ -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);
}

View File

@ -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)
{