KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Using the frameworks on OS X, I can use the following to copy a PNG to the pasteboard (in C — obviously I could use NSPasteboard with Cocoa): #include <ApplicationServices/ApplicationServices.h> int copyThatThing(void) { PasteboardRef clipboard; if (PasteboardCreate(kPasteboardClipboard, &clipboard) != noErr) { return -1; } if (PasteboardClear(clipboard) != noErr) { CFRelease(clipboard); return -1; } size_t len; char *pngbuf = createMyPNGBuffer(&len); /* Defined somewhere else */ if (pngbuf == NULL) { CFRelease(clipboard); return -1; } CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, pngbuf, len, kCFAllocatorNull); if (data == NULL) { CFRelease(clipboard); free(pngbuf); return -1; } OSStatus err; err = PasteboardPutItemFlavor(clipboard, NULL, kUTTypePNG, data, 0); CFRelease(clipboard); CFRelease(data); free(pngbuf); return 0; } I'm interested in porting this functionality to Linux/*BSD platforms. How can I replicate this using X?
Tags (comma-separated)
Save Edits
Cancel