From be85eb8ae6cf65d9d4ede78b4f24dbe8c439b6cb Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 7 Mar 2024 09:50:42 +0000 Subject: [PATCH] add postscript pasteboard type --- Tools/xpbs.m | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Tools/xpbs.m b/Tools/xpbs.m index a3e2ca3e..48bae2da 100644 --- a/Tools/xpbs.m +++ b/Tools/xpbs.m @@ -176,6 +176,11 @@ return NSPasteboardTypePDF; } + if (XG_MIME_PS == type) + { + return NSPostScriptPboardType; + } + if (XG_MIME_PNG == type) { return NSPasteboardTypePNG; @@ -880,6 +885,10 @@ - (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type { [self requestData: (xType = XG_MIME_PDF)]; } + else if ([type isEqual: NSPostScriptPboardType]) + { + [self requestData: (xType = XG_MIME_PS)]; + } else if ([type isEqual: NSHTMLPboardType]) { [self requestData: (xType = XG_MIME_HTML)]; @@ -1374,6 +1383,10 @@ - (void) xSelectionNotify: (XSelectionEvent*)xEvent { [self setData: md]; } + else if (actual_type == XG_MIME_PS) + { + [self setData: md]; + } else if (actual_type == XG_MIME_PNG) { [self setData: md]; @@ -1457,7 +1470,7 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent { unsigned numTypes = 0; // ATTENTION: Increase this array when adding more types - Atom xTypes[22]; + Atom xTypes[23]; /* * The requestor wants a list of the types we can supply it with. @@ -1514,6 +1527,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent xTypes[numTypes++] = XG_MIME_PDF; } + if ([types containsObject: NSPostScriptPboardType]) + { + xTypes[numTypes++] = XG_MIME_PS; + } + if ([types containsObject: NSPasteboardTypePNG]) { xTypes[numTypes++] = XG_MIME_PNG; @@ -1612,6 +1630,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent xEvent->target = XG_MIME_PDF; [self xProvideSelection: xEvent]; } + else if ([types containsObject: NSPostScriptPboardType]) + { + xEvent->target = XG_MIME_PS; + [self xProvideSelection: xEvent]; + } else if ([types containsObject: NSPasteboardTypePNG]) { xEvent->target = XG_MIME_PNG; @@ -1790,6 +1813,14 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent format = 8; numItems = [data length]; } + else if ((xEvent->target == XG_MIME_PS) + && [types containsObject: NSPostScriptPboardType]) + { + data = [_pb dataForType: NSPostScriptPboardType]; + xType = xEvent->target; + format = 8; + numItems = [data length]; + } else if ((xEvent->target == XG_MIME_PNG) && [types containsObject: NSPasteboardTypePNG]) {