aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2022-04-05 20:03:48 +0800
committerPo Lu2022-04-05 20:19:09 +0800
commit7d504c9acc0c8d75d11c3a2b5e016f39e6156bf8 (patch)
tree3207ff8a7d216c4908efcb360e6bc5d9a2b03e0e
parent91ca41e292184bf0c21b55a8e51f3eb1a8c89bb7 (diff)
downloademacs-7d504c9acc0c8d75d11c3a2b5e016f39e6156bf8.tar.gz
emacs-7d504c9acc0c8d75d11c3a2b5e016f39e6156bf8.zip
Mark some data during drag-and-drop
It doesn't make sense to prevent the return frame or movement frame from being deleted, but we should at least protect them from garbage collection. * src/alloc.c (garbage_collect): Call mark_xterm. * src/xterm.c (x_dnd_begin_drag_and_drop) (x_dnd_cleanup_drag_and_drop): Clear movement and return frames upon DND completion. (mark_xterm): Mark those frames. * src/xterm.h: Update prototypes.
-rw-r--r--src/alloc.c4
-rw-r--r--src/xterm.c30
-rw-r--r--src/xterm.h2
3 files changed, 35 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6d91ec33585..733f7733fa9 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6196,6 +6196,10 @@ garbage_collect (void)
6196 mark_fringe_data (); 6196 mark_fringe_data ();
6197#endif 6197#endif
6198 6198
6199#ifdef HAVE_X_WINDOWS
6200 mark_xterm ();
6201#endif
6202
6199 /* Everything is now marked, except for the data in font caches, 6203 /* Everything is now marked, except for the data in font caches,
6200 undo lists, and finalizers. The first two are compacted by 6204 undo lists, and finalizers. The first two are compacted by
6201 removing an items which aren't reachable otherwise. */ 6205 removing an items which aren't reachable otherwise. */
diff --git a/src/xterm.c b/src/xterm.c
index 922aafbbdf1..b9a5355b415 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3497,6 +3497,8 @@ x_dnd_cleanup_drag_and_drop (void *frame)
3497#ifdef USE_GTK 3497#ifdef USE_GTK
3498 current_hold_quit = NULL; 3498 current_hold_quit = NULL;
3499#endif 3499#endif
3500 x_dnd_return_frame_object = NULL;
3501 x_dnd_movement_frame = NULL;
3500 3502
3501 block_input (); 3503 block_input ();
3502 /* Restore the old event mask. */ 3504 /* Restore the old event mask. */
@@ -9528,6 +9530,9 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9528 if (x_dnd_use_toplevels) 9530 if (x_dnd_use_toplevels)
9529 x_dnd_free_toplevels (); 9531 x_dnd_free_toplevels ();
9530 9532
9533 x_dnd_return_frame_object = NULL;
9534 x_dnd_movement_frame = NULL;
9535
9531 FRAME_DISPLAY_INFO (f)->grabbed = 0; 9536 FRAME_DISPLAY_INFO (f)->grabbed = 0;
9532#ifdef USE_GTK 9537#ifdef USE_GTK
9533 current_hold_quit = NULL; 9538 current_hold_quit = NULL;
@@ -9546,6 +9551,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9546#ifdef USE_GTK 9551#ifdef USE_GTK
9547 current_hold_quit = NULL; 9552 current_hold_quit = NULL;
9548#endif 9553#endif
9554 x_dnd_movement_frame = NULL;
9549 9555
9550 /* Restore the old event mask. */ 9556 /* Restore the old event mask. */
9551 XSelectInput (FRAME_X_DISPLAY (f), 9557 XSelectInput (FRAME_X_DISPLAY (f),
@@ -9554,14 +9560,18 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
9554 9560
9555 unblock_input (); 9561 unblock_input ();
9556 9562
9557 if (x_dnd_return_frame == 3) 9563 if (x_dnd_return_frame == 3
9564 && FRAME_LIVE_P (x_dnd_return_frame_object))
9558 { 9565 {
9559 x_dnd_return_frame_object->mouse_moved = true; 9566 x_dnd_return_frame_object->mouse_moved = true;
9560 9567
9561 XSETFRAME (action, x_dnd_return_frame_object); 9568 XSETFRAME (action, x_dnd_return_frame_object);
9569 x_dnd_return_frame_object = NULL;
9562 return action; 9570 return action;
9563 } 9571 }
9564 9572
9573 x_dnd_return_frame_object = NULL;
9574
9565 if (x_dnd_use_toplevels) 9575 if (x_dnd_use_toplevels)
9566 x_dnd_free_toplevels (); 9576 x_dnd_free_toplevels ();
9567 FRAME_DISPLAY_INFO (f)->grabbed = 0; 9577 FRAME_DISPLAY_INFO (f)->grabbed = 0;
@@ -23016,6 +23026,24 @@ init_xterm (void)
23016#endif 23026#endif
23017 23027
23018void 23028void
23029mark_xterm (void)
23030{
23031 Lisp_Object val;
23032
23033 if (x_dnd_return_frame_object)
23034 {
23035 XSETFRAME (val, x_dnd_return_frame_object);
23036 mark_object (val);
23037 }
23038
23039 if (x_dnd_movement_frame)
23040 {
23041 XSETFRAME (val, x_dnd_movement_frame);
23042 mark_object (val);
23043 }
23044}
23045
23046void
23019syms_of_xterm (void) 23047syms_of_xterm (void)
23020{ 23048{
23021 x_error_message = NULL; 23049 x_error_message = NULL;
diff --git a/src/xterm.h b/src/xterm.h
index 79dee6a569c..4eb16d0c142 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1557,6 +1557,8 @@ extern struct frame *x_dnd_frame;
1557struct xi_device_t *xi_device_from_id (struct x_display_info *, int); 1557struct xi_device_t *xi_device_from_id (struct x_display_info *, int);
1558#endif 1558#endif
1559 1559
1560extern void mark_xterm (void);
1561
1560/* Is the frame embedded into another application? */ 1562/* Is the frame embedded into another application? */
1561 1563
1562#define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0) 1564#define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0)