Skip to content

Commit

Permalink
Add support for XG_MIME_PNG and NSPasteboardTypePNG in both copy&paste
Browse files Browse the repository at this point in the history
directions.
  • Loading branch information
rmottola committed Mar 5, 2024
1 parent 6a221b4 commit c901bc8
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions Tools/xpbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,11 @@ - (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type
NSDebugLLog(@"Pbs", @"pasteboard: provideDataForType: - 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
else
{
Expand Down Expand Up @@ -928,6 +933,10 @@ - (NSArray*) availableTypes
{
[types addObject: NSTIFFPboardType];
}
else if (type == XG_MIME_PNG)
{
[types addObject: NSPasteboardTypePNG];
}
else if ((type == XG_TARGETS)
|| (type == XG_TIMESTAMP)
|| (type == XG_OWNER_OS)
Expand Down Expand Up @@ -955,9 +964,10 @@ - (NSArray*) availableTypes
XFree(name);
}

NSDebugLLog(@"Pbs", @"%@ availableTypes: %d types available: %@%@%@%@%@",
[[self osPb] name], count, types,
(txt ? txt : @""), (rtf ? rtf : @""), (std ? std : @""), (bad ? bad : @""));
NSDebugLLog(@"Pbs", @"%@ availableTypes: %d types available: ",
[[self osPb] name], count, types);
NSDebugLLog(@"Pbs", @"\t%@\n\t%@\n\t%@\n\t%@",
(txt ? (NSString *)txt : @""), (rtf ? (NSString *)rtf : @""), (std ? (NSString *)std : @""), (bad ? (NSString *)bad : @""));

return types;
}
Expand Down Expand Up @@ -1257,6 +1267,10 @@ - (void) xSelectionNotify: (XSelectionEvent*)xEvent
{
[self setData: md];
}
else if (actual_type == XG_MIME_PNG)
{
[self setData: md];
}
else if (actual_type == XA_ATOM)
{
// Used when requesting TARGETS to get available types
Expand Down Expand Up @@ -1376,6 +1390,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
xTypes[numTypes++] = XG_MIME_TIFF;
}

if ([types containsObject: NSPasteboardTypePNG])
{
xTypes[numTypes++] = XG_MIME_PNG;
}

xType = XA_ATOM;
format = 32;
data = [NSData dataWithBytes: (const void*)xTypes
Expand Down Expand Up @@ -1601,6 +1620,14 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
format = 8;
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
else
{
Expand Down

0 comments on commit c901bc8

Please sign in to comment.