Add URL/URI-list support (without insisting on trailing cr-lf)

This commit is contained in:
rfm 2024-03-06 20:47:04 +00:00
parent 0d60ea2935
commit 085082a6cc

View file

@ -166,6 +166,11 @@ NSPasteboardTypeFromAtom(Atom type)
return NSHTMLPboardType;
}
if (XG_MIME_URI == type)
{
return NSURLPboardType;
}
if (XG_MIME_PDF == type)
{
return NSPasteboardTypePDF;
@ -879,6 +884,10 @@ static int xFixesEventBase;
{
[self requestData: (xType = XG_MIME_HTML)];
}
else if ([type isEqual: NSURLPboardType])
{
[self requestData: (xType = XG_MIME_URI)];
}
// FIXME: Support more types
else
{
@ -1353,6 +1362,10 @@ xErrorHandler(Display *d, XErrorEvent *e)
{
[self setData: md];
}
else if (actual_type == XG_MIME_URI)
{
[self setData: md];
}
else if (actual_type == XG_MIME_TIFF)
{
[self setData: md];
@ -1444,7 +1457,7 @@ xErrorHandler(Display *d, XErrorEvent *e)
{
unsigned numTypes = 0;
// ATTENTION: Increase this array when adding more types
Atom xTypes[21];
Atom xTypes[22];
/*
* The requestor wants a list of the types we can supply it with.
@ -1486,6 +1499,11 @@ xErrorHandler(Display *d, XErrorEvent *e)
xTypes[numTypes++] = XG_MIME_XHTML;
}
if ([types containsObject: NSURLPboardType])
{
xTypes[numTypes++] = XG_MIME_URI;
}
if ([types containsObject: NSTIFFPboardType])
{
xTypes[numTypes++] = XG_MIME_TIFF;
@ -1604,6 +1622,11 @@ xErrorHandler(Display *d, XErrorEvent *e)
xEvent->target = XG_MIME_HTML;
[self xProvideSelection: xEvent];
}
else if ([types containsObject: NSURLPboardType])
{
xEvent->target = XG_MIME_URI;
[self xProvideSelection: xEvent];
}
}
else if (xEvent->target == XG_MULTIPLE)
{
@ -1743,6 +1766,14 @@ xErrorHandler(Display *d, XErrorEvent *e)
format = 8;
numItems = [data length];
}
else if ((xEvent->target == XG_MIME_URI)
&& [types containsObject: NSURLPboardType])
{
data = [_pb dataForType: NSURLPboardType];
xType = xEvent->target;
format = 8;
numItems = [data length];
}
else if ((xEvent->target == XG_MIME_TIFF)
&& [types containsObject: NSTIFFPboardType])
{