emacs-diffs
[Top][All Lists]
Advanced

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

master cce37ac9f4c 2/2: Improve some behavior when the X server does not


From: Po Lu
Subject: master cce37ac9f4c 2/2: Improve some behavior when the X server does not trust Emacs
Date: Fri, 9 Dec 2022 05:30:35 -0500 (EST)

branch: master
commit cce37ac9f4c66d927d1acae75763e5fb56632783
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Improve some behavior when the X server does not trust Emacs
    
    * src/xterm.c (x_dnd_begin_drag_and_drop): Display error when
    Emacs is untrusted instead of hanging indefinitely.
    (x_focus_frame): Simply return instead of wasting time when
    Emacs is untrusted.
---
 src/xterm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 4c859c46c31..872326392a6 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12308,6 +12308,13 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, 
Atom xaction,
   struct xi_device_t *device;
 #endif
 
+  if (FRAME_DISPLAY_INFO (f)->untrusted)
+    /* Untrusted clients cannot send messages to trusted clients or
+       read the window tree, so drag and drop will likely not work at
+       all.  */
+    error ("Drag-and-drop is not possible when the client is"
+          " not trusted by the X server.");
+
   base = SPECPDL_INDEX ();
 
   /* Bind this here to avoid juggling bindings and SAFE_FREE in
@@ -27949,12 +27956,17 @@ x_focus_frame (struct frame *f, bool noactivate)
   struct x_display_info *dpyinfo;
   Time time;
 
+  dpyinfo = FRAME_DISPLAY_INFO (f);
+
+  if (dpyinfo->untrusted)
+    /* The X server ignores all input focus related requests from
+       untrusted clients.  */
+    return;
+
   /* The code below is not reentrant wrt to dpyinfo->x_focus_frame and
      friends being set.  */
   block_input ();
 
-  dpyinfo = FRAME_DISPLAY_INFO (f);
-
   if (FRAME_X_EMBEDDED_P (f))
     /* For Xembedded frames, normally the embedder forwards key
        events.  See XEmbed Protocol Specification at



reply via email to

[Prev in Thread] Current Thread [Next in Thread]