Bloody Apple native apps refuse to accept drops if a private MIME type is present. Sigh. Back to the drawing board.

This commit is contained in:
Kovid Goyal 2026-05-14 08:25:58 +05:30
parent f2c79ed7c7
commit 5eee2c54ce
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -4379,20 +4379,17 @@ - (void)draggingSession:(NSDraggingSession *)session
static int
add_drag_items(_GLFWwindow *window, NSMutableArray<NSDraggingItem*>* dragItems, GLFWDragSourceItem *mime_item, const GLFWimage *thumbnail) {
// URI list items get added directly to the clipboard for use by native apps since macOS does not support
// the text/uri-list MIME type, however this type remains as a private
// kitty type to enable kitty to kitty DnD for remote clients.
bool is_uri_list = false;
// the text/uri-list MIME type
if (strcmp(mime_item->mime_type, "text/uri-list") == 0 && mime_item->optional_data && mime_item->data_size) {
is_uri_list = true;
int err = add_uri_list_drag_items(window, dragItems, mime_item->optional_data, mime_item->data_size, mime_item->is_remote_client, thumbnail);
if (err != 0) return err;
return add_uri_list_drag_items(
window, dragItems, mime_item->optional_data, mime_item->data_size, mime_item->is_remote_client, thumbnail);
}
NSString* utiString = mime_to_uti(mime_item->mime_type);
id w;
// remote client URI list must be set a file promise so that the kitty drag
// source code receives a request for it and can then fetch the remote
// files.
if (mime_item->optional_data && !(is_uri_list && mime_item->is_remote_client)) {
if (mime_item->optional_data) {
NSPasteboardItem *pbItem = [[[NSPasteboardItem alloc] init] autorelease];
NSData *data = [NSData dataWithBytes:mime_item->optional_data length:mime_item->data_size];
[pbItem setData:data forType:utiString];