Add support for XG_MIME_PNG and NSPasteboardTypePNG in both copy&paste

directions.
This commit is contained in:
Riccardo Mottola 2024-03-05 11:13:33 +01:00
parent 6a221b4dc7
commit c901bc8cd2

View file

@ -789,6 +789,11 @@ static int xFixesEventBase;
NSDebugLLog(@"Pbs", @"pasteboard: provideDataForType: - requestData XG_MIME_TIFF"); NSDebugLLog(@"Pbs", @"pasteboard: provideDataForType: - requestData XG_MIME_TIFF");
[self requestData: XG_MIME_TIFF]; [self requestData: XG_MIME_TIFF];
} }
else if ([type isEqual: NSPasteboardTypePNG])
{
NSDebugLLog(@"Pbs", @"pasteboard: provideDataForType: - requestData XG_MIME_PNG");
[self requestData: XG_MIME_PNG];
}
// FIXME: Support more types // FIXME: Support more types
else else
{ {
@ -928,6 +933,10 @@ xErrorHandler(Display *d, XErrorEvent *e)
{ {
[types addObject: NSTIFFPboardType]; [types addObject: NSTIFFPboardType];
} }
else if (type == XG_MIME_PNG)
{
[types addObject: NSPasteboardTypePNG];
}
else if ((type == XG_TARGETS) else if ((type == XG_TARGETS)
|| (type == XG_TIMESTAMP) || (type == XG_TIMESTAMP)
|| (type == XG_OWNER_OS) || (type == XG_OWNER_OS)
@ -955,9 +964,10 @@ xErrorHandler(Display *d, XErrorEvent *e)
XFree(name); XFree(name);
} }
NSDebugLLog(@"Pbs", @"%@ availableTypes: %d types available: %@%@%@%@%@", NSDebugLLog(@"Pbs", @"%@ availableTypes: %d types available: ",
[[self osPb] name], count, types, [[self osPb] name], count, types);
(txt ? txt : @""), (rtf ? rtf : @""), (std ? std : @""), (bad ? bad : @"")); NSDebugLLog(@"Pbs", @"\t%@\n\t%@\n\t%@\n\t%@",
(txt ? (NSString *)txt : @""), (rtf ? (NSString *)rtf : @""), (std ? (NSString *)std : @""), (bad ? (NSString *)bad : @""));
return types; return types;
} }
@ -1257,6 +1267,10 @@ xErrorHandler(Display *d, XErrorEvent *e)
{ {
[self setData: md]; [self setData: md];
} }
else if (actual_type == XG_MIME_PNG)
{
[self setData: md];
}
else if (actual_type == XA_ATOM) else if (actual_type == XA_ATOM)
{ {
// Used when requesting TARGETS to get available types // Used when requesting TARGETS to get available types
@ -1376,6 +1390,11 @@ xErrorHandler(Display *d, XErrorEvent *e)
xTypes[numTypes++] = XG_MIME_TIFF; xTypes[numTypes++] = XG_MIME_TIFF;
} }
if ([types containsObject: NSPasteboardTypePNG])
{
xTypes[numTypes++] = XG_MIME_PNG;
}
xType = XA_ATOM; xType = XA_ATOM;
format = 32; format = 32;
data = [NSData dataWithBytes: (const void*)xTypes data = [NSData dataWithBytes: (const void*)xTypes
@ -1601,6 +1620,14 @@ xErrorHandler(Display *d, XErrorEvent *e)
format = 8; format = 8;
numItems = [data length]; numItems = [data length];
} }
else if ((xEvent->target == XG_MIME_PNG)
&& [types containsObject: NSPasteboardTypePNG])
{
data = [_pb dataForType: NSPasteboardTypePNG];
xType = xEvent->target;
format = 8;
numItems = [data length];
}
// FIXME: Support more types // FIXME: Support more types
else else
{ {