emacs-diffs
[Top][All Lists]
Advanced

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

master 1fed6e7b56: Handle errors getting selection ownership when starti


From: Po Lu
Subject: master 1fed6e7b56: Handle errors getting selection ownership when starting DND
Date: Fri, 15 Apr 2022 20:55:55 -0400 (EDT)

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

    Handle errors getting selection ownership when starting DND
    
    * src/xterm.c (x_clear_dnd_targets): New function.
    (x_dnd_begin_drag_and_drop): Handle errors in `x_own_selection'.
---
 src/xterm.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index f80b2ad2f0..c5b31553ae 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9435,6 +9435,13 @@ x_top_window_to_frame (struct x_display_info *dpyinfo, 
int wdesc)
 
 #endif /* USE_X_TOOLKIT || USE_GTK */
 
+static void
+x_clear_dnd_targets (void)
+{
+  if (x_dnd_unwind_flag)
+    x_set_dnd_targets (NULL, 0);
+}
+
 /* This function is defined far away from the rest of the XDND code so
    it can utilize `x_any_window_to_frame'.  */
 
@@ -9479,8 +9486,16 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, 
Atom xaction,
     }
 
   if (CONSP (local_value))
-    x_own_selection (QXdndSelection,
-                    Fnth (make_fixnum (1), local_value), frame);
+    {
+      ref = SPECPDL_INDEX ();
+
+      record_unwind_protect_void (x_clear_dnd_targets);
+      x_dnd_unwind_flag = true;
+      x_own_selection (QXdndSelection,
+                      Fnth (make_fixnum (1), local_value), frame);
+      x_dnd_unwind_flag = false;
+      unbind_to (ref, Qnil);
+    }
   else
     {
       x_set_dnd_targets (NULL, 0);



reply via email to

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