diff options
author | Po Lu <luangruo@yahoo.com> | 2022-04-12 16:36:42 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-04-12 16:38:02 +0800 |
commit | 78784ccfadaee1c86207ecc360db7236285713f5 (patch) | |
tree | c4c3487d2186e8fa910a045f8a1408325956750f | |
parent | 17f0900d7bd783375e07f642cf8740c3e1dbaa8f (diff) | |
download | emacs-78784ccfadaee1c86207ecc360db7236285713f5.tar.gz |
Disallow drag and drop inside a menu-entry
* src/xterm.c (x_dnd_cleanup_drag_and_drop): Always free DND
targets even if waiting for finish.
(x_dnd_begin_drag_and_drop): Free targets correctly when
signalling error and prevent activating drag-and-drop inside a
menu or popup. (It doesn't work.)
-rw-r--r-- | src/xterm.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/xterm.c b/src/xterm.c index b1d9ca7361b..1bc92c67c0e 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3571,9 +3571,9 @@ x_dnd_cleanup_drag_and_drop (void *frame) x_dnd_last_seen_window = None; x_dnd_last_seen_toplevel = None; x_dnd_in_progress = false; - x_set_dnd_targets (NULL, 0); } + x_set_dnd_targets (NULL, 0); x_dnd_waiting_for_finish = false; if (x_dnd_use_toplevels) @@ -9373,20 +9373,35 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, Lisp_Object frame_object, x, y, frame, local_value; if (!FRAME_VISIBLE_P (f)) - error ("Frame is invisible"); + { + x_set_dnd_targets (NULL, 0); + error ("Frame is invisible"); + } XSETFRAME (frame, f); local_value = assq_no_quit (QXdndSelection, FRAME_TERMINAL (f)->Vselection_alist); if (x_dnd_in_progress || x_dnd_waiting_for_finish) - error ("A drag-and-drop session is already in progress"); + { + x_set_dnd_targets (NULL, 0); + error ("A drag-and-drop session is already in progress"); + } if (CONSP (local_value)) x_own_selection (QXdndSelection, Fnth (make_fixnum (1), local_value), frame); else - error ("No local value for XdndSelection"); + { + x_set_dnd_targets (NULL, 0); + error ("No local value for XdndSelection"); + } + + if (popup_activated ()) + { + x_set_dnd_targets (NULL, 0); + error ("Trying to drag-and-drop from within a menu-entry"); + } ltimestamp = x_timestamp_for_selection (FRAME_DISPLAY_INFO (f), QXdndSelection); @@ -9624,9 +9639,9 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, x_dnd_last_seen_toplevel = None; x_dnd_in_progress = false; x_dnd_frame = NULL; - x_set_dnd_targets (NULL, 0); } + x_set_dnd_targets (NULL, 0); x_dnd_waiting_for_finish = false; if (x_dnd_use_toplevels) @@ -9647,6 +9662,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, quit (); } } + x_set_dnd_targets (NULL, 0); x_dnd_waiting_for_finish = false; |