summaryrefslogtreecommitdiff
path: root/src/haikuselect.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-04-06 05:54:31 +0000
committerPo Lu <luangruo@yahoo.com>2022-04-06 05:54:31 +0000
commit78ecd67888566167fb4c881d8350f611fa039649 (patch)
tree7a53184f780c47732c3782c0f69fcc8e8c7420a4 /src/haikuselect.c
parenta6f7d0f4e38555080bbdb45dbb414e15d206f548 (diff)
downloademacs-78ecd67888566167fb4c881d8350f611fa039649.tar.gz
emacs-78ecd67888566167fb4c881d8350f611fa039649.tar.bz2
emacs-78ecd67888566167fb4c881d8350f611fa039649.zip
Improve safety of haiku-drag-message
* lisp/term/haiku-win.el (haiku-drag-and-drop): Ignore placeholder message. * src/frame.c (delete_frame): Prevent deleting drop source frame on Haiku. * src/haiku_support.cc (RELEASE_NOW, CANCEL_DROP): New message types. (class EmacsView, MessageReceived): Handle new message types. (be_drag_message): Drag CANCEL_DROP message on quit; also send RELEASE_NOW to view if quitting. * src/haikuselect.c (syms_of_haikuselect) (haiku_unwind_drag_message): Clear new frame variable. (Fhaiku_drag_message): Set new frame variable. * src/haikuterm.h: Update prototypes.
Diffstat (limited to 'src/haikuselect.c')
-rw-r--r--src/haikuselect.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/haikuselect.c b/src/haikuselect.c
index c3053688f5a..a186acc66ff 100644
--- a/src/haikuselect.c
+++ b/src/haikuselect.c
@@ -27,6 +27,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <stdlib.h>
+/* The frame that is currently the source of a drag-and-drop
+ operation, or NULL if none is in progress. The reason for this
+ variable is to prevent it from being deleted, which really breaks
+ the nested event loop inside be_drag_message. */
+struct frame *haiku_dnd_frame;
+
static void haiku_lisp_to_message (Lisp_Object, void *);
DEFUN ("haiku-selection-data", Fhaiku_selection_data, Shaiku_selection_data,
@@ -726,6 +732,7 @@ haiku_should_quit_drag (void)
static void
haiku_unwind_drag_message (void *message)
{
+ haiku_dnd_frame = NULL;
BMessage_delete (message);
}
@@ -774,6 +781,7 @@ ignored if it is dropped on top of FRAME. */)
if (!FRAME_VISIBLE_P (f))
error ("Frame is invisible");
+ haiku_dnd_frame = f;
be_message = be_create_simple_message ();
record_unwind_protect_ptr (haiku_unwind_drag_message, be_message);
@@ -852,4 +860,6 @@ used to retrieve the current position of the mouse. */);
defsubr (&Shaiku_selection_put);
defsubr (&Shaiku_selection_owner_p);
defsubr (&Shaiku_drag_message);
+
+ haiku_dnd_frame = NULL;
}