Register UTI for tab drag mime on Cocoa

This commit is contained in:
Kovid Goyal
2026-02-21 16:59:58 +05:30
parent aab60b7967
commit 7efba91ffc

View File

@@ -40,7 +40,6 @@
#define debug debug_rendering #define debug debug_rendering
// Macro and forward declaration needed before draggingEntered: (uti_to_mime is defined in Clipboard section)
#define UTI_ROUNDTRIP_PREFIX @"uti-is-typical-apple-nih." #define UTI_ROUNDTRIP_PREFIX @"uti-is-typical-apple-nih."
static NSString* static NSString*
@@ -867,18 +866,17 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
self.identifier = @"kitty-content-view"; self.identifier = @"kitty-content-view";
[self updateTrackingAreas]; [self updateTrackingAreas];
// Register for file promises in addition to regular files (macOS 10.12+) char tab_mime[64];
if (@available(macOS 10.12, *)) { snprintf(tab_mime, sizeof(tab_mime), "application/net.kovidgoyal.kitty-tab-%d", getpid());
NSMutableArray *types = [NSMutableArray arrayWithObjects: NSMutableArray *types = [NSMutableArray arrayWithObjects:
NSPasteboardTypeFileURL, NSPasteboardTypeFileURL, NSPasteboardTypeString, NSPasteboardTypeURL, NSPasteboardTypeColor,
NSPasteboardTypeString, NSPasteboardTypeFont, NSPasteboardTypeHTML, NSPasteboardTypePDF, NSPasteboardTypePNG,
nil]; NSPasteboardTypeRTF, NSPasteboardTypeSound, NSPasteboardTypeTIFF,
// Add file promise types mime_to_uti(tab_mime),
[types addObjectsFromArray:[NSFilePromiseReceiver readableDraggedTypes]]; nil];
[self registerForDraggedTypes:types]; // Add file promise types
} else { [types addObjectsFromArray:[NSFilePromiseReceiver readableDraggedTypes]];
[self registerForDraggedTypes:@[NSPasteboardTypeFileURL, NSPasteboardTypeString]]; [self registerForDraggedTypes:types];
}
} }
return self; return self;