summaryrefslogtreecommitdiff
path: root/src/haiku_select.cc
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-03-16 13:18:12 +0000
committerPo Lu <luangruo@yahoo.com>2022-03-16 13:28:53 +0000
commit3de3f12b9402c731aca1a583a15fc6245efea136 (patch)
treedd0b83c98156cb6aecd01d40bdda7ef20df05844 /src/haiku_select.cc
parent65f92837fa58c943f689fb847edcfd44c8a8a6c1 (diff)
downloademacs-3de3f12b9402c731aca1a583a15fc6245efea136.tar.gz
Redo Haiku DND support
* lisp/term/haiku-win.el (haiku-dnd-handle-drag-n-drop-event): Update for new DND event format. * src/haiku_io.c (haiku_len): Handle DRAG_AND_DROP_EVENTs. * src/haiku_select.cc (be_enum_message, be_get_refs_data) (be_get_message_data): New function. * src/haiku_support.cc (class Emacs): Remove `RefsReceived'. (MessageReceived): Generate new kind of drag-n-drop events. * src/haiku_support.h (enum haiku_event_type): Rename `REFS_EVENT' to `DRAG_AND_DROP_EVENT'. (struct haiku_refs_event): Delete struct. (struct haiku_drag_and_drop_event): New struct. * src/haikuselect.c (haiku_message_to_lisp): New function. (syms_of_haikuselect): New symbols. * src/haikuselect.h: Update prototypes. * src/haikuterm.c (haiku_read_socket): Handle new type of drag-and-drop events by serializing drop message to Lisp and letting Lisp code do the processing. * src/haikuterm.h: Update prototypes.
Diffstat (limited to 'src/haiku_select.cc')
-rw-r--r--src/haiku_select.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/haiku_select.cc b/src/haiku_select.cc
index 011ad58036f..abb07b20028 100644
--- a/src/haiku_select.cc
+++ b/src/haiku_select.cc
@@ -19,6 +19,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include <Clipboard.h>
+#include <Message.h>
+#include <Path.h>
+#include <Entry.h>
#include <cstdlib>
#include <cstring>
@@ -257,3 +260,64 @@ init_haiku_select (void)
primary = new BClipboard ("primary");
secondary = new BClipboard ("secondary");
}
+
+int
+be_enum_message (void *message, int32 *tc, int32 index,
+ int32 *count, const char **name_return)
+{
+ BMessage *msg = (BMessage *) message;
+ type_code type;
+ char *name;
+ status_t rc;
+
+ rc = msg->GetInfo (B_ANY_TYPE, index, &name, &type, count);
+
+ if (rc != B_OK)
+ return 1;
+
+ *tc = type;
+ *name_return = name;
+ return 0;
+}
+
+int
+be_get_refs_data (void *message, const char *name,
+ int32 index, char **path_buffer)
+{
+ status_t rc;
+ BEntry entry;
+ BPath path;
+ entry_ref ref;
+ BMessage *msg;
+
+ msg = (BMessage *) message;
+ rc = msg->FindRef (name, index, &ref);
+
+ if (rc != B_OK)
+ return 1;
+
+ rc = entry.SetTo (&ref, 0);
+
+ if (rc != B_OK)
+ return 1;
+
+ rc = entry.GetPath (&path);
+
+ if (rc != B_OK)
+ return 1;
+
+ *path_buffer = strdup (path.Path ());
+ return 0;
+}
+
+int
+be_get_message_data (void *message, const char *name,
+ int32 type_code, int32 index,
+ const void **buf_return,
+ ssize_t *size_return)
+{
+ BMessage *msg = (BMessage *) message;
+
+ return msg->FindData (name, type_code,
+ index, buf_return, size_return) != B_OK;
+}