]> git.eshelyaron.com Git - emacs.git/commitdiff
Work around sample server bug
authorPo Lu <luangruo@yahoo.com>
Tue, 6 Dec 2022 11:30:15 +0000 (19:30 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 6 Dec 2022 11:30:30 +0000 (19:30 +0800)
* src/xterm.c (XTring_bell): Catch Access errors from XBell when
Emacs is running as an untrusted client.

src/xterm.c

index ab31f0d93e6e44c568302c7f4c0947d870cb3347..f446d093ef4cd785c54c78816b22605106ef00ee 100644 (file)
@@ -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 ();
     }
 }