(if (multibyte-string-p text)
text
(decode-coding-string text 'undecided))))))
- (t (message "Don't know how to drop any of: %s"
- (mapcar #'car string)))))))
+ ((not (eq (cdr (assq 'type string))
+ 3003)) ; Type of the placeholder message Emacs uses
+ ; to cancel a drop on C-g.
+ (message "Don't know how to drop any of: %s"
+ (mapcar #'car string)))))))
(define-key special-event-map [drag-n-drop]
'haiku-drag-and-drop)
else if (x_dnd_in_progress && f == x_dnd_frame)
error ("Attempt to delete the drop source frame");
#endif
+#ifdef HAVE_HAIKU
+ else if (f == haiku_dnd_frame)
+ error ("Attempt to delete the drop source frame");
+#endif
XSETFRAME (frame, f);
#include "haiku_support.h"
-#define SCROLL_BAR_UPDATE 3000
-#define WAIT_FOR_RELEASE 3001
+enum
+ {
+ SCROLL_BAR_UPDATE = 3000,
+ WAIT_FOR_RELEASE = 3001,
+ RELEASE_NOW = 3002,
+ CANCEL_DROP = 3003,
+ };
static color_space dpy_color_space = B_NO_COLOR_SPACE;
static key_map *key_map = NULL;
~EmacsView ()
{
if (wait_for_release_message)
- gui_abort ("Wait for release message still exists");
+ {
+ wait_for_release_message->SendReply (wait_for_release_message);
+ delete wait_for_release_message;
+ }
TearDownDoubleBuffering ();
else
wait_for_release_message = looper->DetachCurrentMessage ();
}
+ else if (msg->what == RELEASE_NOW)
+ {
+ if (wait_for_release_message)
+ wait_for_release_message->SendReply (msg);
+
+ delete wait_for_release_message;
+ wait_for_release_message = NULL;
+ }
else
BView::MessageReceived (msg);
}
BMessage *msg = (BMessage *) message;
BMessage wait_for_release;
BMessenger messenger (vw);
+ BMessage cancel_message (CANCEL_DROP);
struct object_wait_info infos[2];
ssize_t stat;
if (should_quit_function ())
{
+ /* Do the best we can to prevent something from being
+ dropped, since Haiku doesn't provide a way to actually
+ cancel drag-and-drop. */
+ if (vw->LockLooper ())
+ {
+ vw->DragMessage (&cancel_message, BRect (0, 0, 0, 0));
+ vw->UnlockLooper ();
+ }
+
+ messenger.SendMessage (CANCEL_DROP);
drag_and_drop_in_progress = false;
return true;
}
#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,
static void
haiku_unwind_drag_message (void *message)
{
+ haiku_dnd_frame = NULL;
BMessage_delete (message);
}
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);
defsubr (&Shaiku_selection_put);
defsubr (&Shaiku_selection_owner_p);
defsubr (&Shaiku_drag_message);
+
+ haiku_dnd_frame = NULL;
}
extern struct font_driver const haikufont_driver;
extern Lisp_Object tip_frame;
+extern struct frame *haiku_dnd_frame;
struct scroll_bar
{