From: Po Lu Date: Tue, 6 Dec 2022 11:30:15 +0000 (+0800) Subject: Work around sample server bug X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f803203088c26e8906ae28e9b27cc6afa37fb8cb;p=emacs.git Work around sample server bug * src/xterm.c (XTring_bell): Catch Access errors from XBell when Emacs is running as an untrusted client. --- diff --git a/src/xterm.c b/src/xterm.c index ab31f0d93e6..f446d093ef4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -11251,21 +11251,32 @@ XTflash (struct frame *f) static void XTring_bell (struct frame *f) { - if (FRAME_X_DISPLAY (f)) + struct x_display_info *dpyinfo; + + if (!FRAME_X_DISPLAY (f)) + return; + + dpyinfo = FRAME_DISPLAY_INFO (f); + + if (visible_bell) + XTflash (f); + else { - if (visible_bell) - XTflash (f); - else - { - block_input (); + /* When Emacs is untrusted, Bell requests sometimes generate + Access errors. This is not in the security extension + specification but seems to be a bug in the X consortium XKB + implementation. */ + + block_input (); + x_ignore_errors_for_next_request (dpyinfo); #ifdef HAVE_XKB - XkbBell (FRAME_X_DISPLAY (f), None, 0, None); + XkbBell (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 0, None); #else - XBell (FRAME_X_DISPLAY (f), 0); + XBell (FRAME_X_DISPLAY (f), 0); #endif - XFlush (FRAME_X_DISPLAY (f)); - unblock_input (); - } + XFlush (FRAME_X_DISPLAY (f)); + x_stop_ignoring_errors (dpyinfo); + unblock_input (); } }