diff options
| author | Po Lu | 2022-04-12 16:36:42 +0800 |
|---|---|---|
| committer | Po Lu | 2022-04-12 16:38:02 +0800 |
| commit | 78784ccfadaee1c86207ecc360db7236285713f5 (patch) | |
| tree | c4c3487d2186e8fa910a045f8a1408325956750f /src | |
| parent | 17f0900d7bd783375e07f642cf8740c3e1dbaa8f (diff) | |
| download | emacs-78784ccfadaee1c86207ecc360db7236285713f5.tar.gz emacs-78784ccfadaee1c86207ecc360db7236285713f5.zip | |
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.)
Diffstat (limited to 'src')
| -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) | |||
| 3571 | x_dnd_last_seen_window = None; | 3571 | x_dnd_last_seen_window = None; |
| 3572 | x_dnd_last_seen_toplevel = None; | 3572 | x_dnd_last_seen_toplevel = None; |
| 3573 | x_dnd_in_progress = false; | 3573 | x_dnd_in_progress = false; |
| 3574 | x_set_dnd_targets (NULL, 0); | ||
| 3575 | } | 3574 | } |
| 3576 | 3575 | ||
| 3576 | x_set_dnd_targets (NULL, 0); | ||
| 3577 | x_dnd_waiting_for_finish = false; | 3577 | x_dnd_waiting_for_finish = false; |
| 3578 | 3578 | ||
| 3579 | if (x_dnd_use_toplevels) | 3579 | if (x_dnd_use_toplevels) |
| @@ -9373,20 +9373,35 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, | |||
| 9373 | Lisp_Object frame_object, x, y, frame, local_value; | 9373 | Lisp_Object frame_object, x, y, frame, local_value; |
| 9374 | 9374 | ||
| 9375 | if (!FRAME_VISIBLE_P (f)) | 9375 | if (!FRAME_VISIBLE_P (f)) |
| 9376 | error ("Frame is invisible"); | 9376 | { |
| 9377 | x_set_dnd_targets (NULL, 0); | ||
| 9378 | error ("Frame is invisible"); | ||
| 9379 | } | ||
| 9377 | 9380 | ||
| 9378 | XSETFRAME (frame, f); | 9381 | XSETFRAME (frame, f); |
| 9379 | local_value = assq_no_quit (QXdndSelection, | 9382 | local_value = assq_no_quit (QXdndSelection, |
| 9380 | FRAME_TERMINAL (f)->Vselection_alist); | 9383 | FRAME_TERMINAL (f)->Vselection_alist); |
| 9381 | 9384 | ||
| 9382 | if (x_dnd_in_progress || x_dnd_waiting_for_finish) | 9385 | if (x_dnd_in_progress || x_dnd_waiting_for_finish) |
| 9383 | error ("A drag-and-drop session is already in progress"); | 9386 | { |
| 9387 | x_set_dnd_targets (NULL, 0); | ||
| 9388 | error ("A drag-and-drop session is already in progress"); | ||
| 9389 | } | ||
| 9384 | 9390 | ||
| 9385 | if (CONSP (local_value)) | 9391 | if (CONSP (local_value)) |
| 9386 | x_own_selection (QXdndSelection, | 9392 | x_own_selection (QXdndSelection, |
| 9387 | Fnth (make_fixnum (1), local_value), frame); | 9393 | Fnth (make_fixnum (1), local_value), frame); |
| 9388 | else | 9394 | else |
| 9389 | error ("No local value for XdndSelection"); | 9395 | { |
| 9396 | x_set_dnd_targets (NULL, 0); | ||
| 9397 | error ("No local value for XdndSelection"); | ||
| 9398 | } | ||
| 9399 | |||
| 9400 | if (popup_activated ()) | ||
| 9401 | { | ||
| 9402 | x_set_dnd_targets (NULL, 0); | ||
| 9403 | error ("Trying to drag-and-drop from within a menu-entry"); | ||
| 9404 | } | ||
| 9390 | 9405 | ||
| 9391 | ltimestamp = x_timestamp_for_selection (FRAME_DISPLAY_INFO (f), | 9406 | ltimestamp = x_timestamp_for_selection (FRAME_DISPLAY_INFO (f), |
| 9392 | QXdndSelection); | 9407 | QXdndSelection); |
| @@ -9624,9 +9639,9 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, | |||
| 9624 | x_dnd_last_seen_toplevel = None; | 9639 | x_dnd_last_seen_toplevel = None; |
| 9625 | x_dnd_in_progress = false; | 9640 | x_dnd_in_progress = false; |
| 9626 | x_dnd_frame = NULL; | 9641 | x_dnd_frame = NULL; |
| 9627 | x_set_dnd_targets (NULL, 0); | ||
| 9628 | } | 9642 | } |
| 9629 | 9643 | ||
| 9644 | x_set_dnd_targets (NULL, 0); | ||
| 9630 | x_dnd_waiting_for_finish = false; | 9645 | x_dnd_waiting_for_finish = false; |
| 9631 | 9646 | ||
| 9632 | if (x_dnd_use_toplevels) | 9647 | if (x_dnd_use_toplevels) |
| @@ -9647,6 +9662,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, | |||
| 9647 | quit (); | 9662 | quit (); |
| 9648 | } | 9663 | } |
| 9649 | } | 9664 | } |
| 9665 | |||
| 9650 | x_set_dnd_targets (NULL, 0); | 9666 | x_set_dnd_targets (NULL, 0); |
| 9651 | x_dnd_waiting_for_finish = false; | 9667 | x_dnd_waiting_for_finish = false; |
| 9652 | 9668 | ||