Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for XG_MIME_PNG and NSPasteboardTypePNG in both copy&paste directions. #47

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to increase the size of xTypes in line 1353.

}

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
Loading