aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/mac.m')
-rw-r--r--src/mac.m61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/mac.m b/src/mac.m
index 2d492a9..6da3cf7 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -1867,6 +1867,19 @@ puglSetTransientParent(PuglView* view, PuglNativeView parent)
return PUGL_FAILURE;
}
+static NSPasteboard*
+getPasteboard(const PuglView* const view, const PuglClipboard clipboard)
+{
+ (void)view;
+
+ switch (clipboard) {
+ case PUGL_CLIPBOARD_GENERAL:
+ return [NSPasteboard generalPasteboard];
+ }
+
+ return NULL;
+}
+
PuglStatus
puglPaste(PuglView* const view)
{
@@ -1883,18 +1896,20 @@ puglPaste(PuglView* const view)
}
uint32_t
-puglGetNumClipboardTypes(const PuglView* PUGL_UNUSED(view))
+puglGetNumClipboardTypes(const PuglView* const view,
+ const PuglClipboard clipboard)
{
- NSPasteboard* const pasteboard = [NSPasteboard generalPasteboard];
+ NSPasteboard* const pasteboard = getPasteboard(view, clipboard);
return pasteboard ? (uint32_t)[[pasteboard types] count] : 0;
}
const char*
-puglGetClipboardType(const PuglView* PUGL_UNUSED(view),
- const uint32_t typeIndex)
+puglGetClipboardType(const PuglView* const view,
+ const PuglClipboard clipboard,
+ const uint32_t typeIndex)
{
- NSPasteboard* const pasteboard = [NSPasteboard generalPasteboard];
+ NSPasteboard* const pasteboard = getPasteboard(view, clipboard);
if (!pasteboard) {
return NULL;
}
@@ -1918,7 +1933,7 @@ puglAcceptOffer(PuglView* const view,
const PuglRect region)
{
PuglWrapperView* const wrapper = view->impl->wrapperView;
- NSPasteboard* const pasteboard = [NSPasteboard generalPasteboard];
+ NSPasteboard* const pasteboard = getPasteboard(view, offer->clipboard);
if (!pasteboard) {
return PUGL_BAD_PARAMETER;
}
@@ -1945,13 +1960,14 @@ puglAcceptOffer(PuglView* const view,
}
const void*
-puglGetClipboard(PuglView* const view,
- const uint32_t typeIndex,
- size_t* const len)
+puglGetClipboard(PuglView* const view,
+ const PuglClipboard clipboard,
+ const uint32_t typeIndex,
+ size_t* const len)
{
*len = 0;
- NSPasteboard* const pasteboard = [NSPasteboard generalPasteboard];
+ NSPasteboard* const pasteboard = getPasteboard(view, clipboard);
if (!pasteboard) {
return NULL;
}
@@ -2035,20 +2051,23 @@ puglSetCursor(PuglView* view, PuglCursor cursor)
}
PuglStatus
-puglSetClipboard(PuglView* PUGL_UNUSED(view),
- const char* const type,
- const void* const data,
- const size_t len)
+puglSetClipboard(PuglView* PUGL_UNUSED(view),
+ const PuglClipboard clipboard,
+ const char* const type,
+ const void* const data,
+ const size_t len)
{
- NSPasteboard* const pasteboard = [NSPasteboard generalPasteboard];
- NSString* const mimeType = [NSString stringWithUTF8String:type];
- NSString* const uti = utiForMimeType(mimeType);
- NSData* const blob = [NSData dataWithBytes:data length:len];
+ if (clipboard == PUGL_CLIPBOARD_GENERAL) {
+ NSPasteboard* const pasteboard = [NSPasteboard generalPasteboard];
+ NSString* const mimeType = [NSString stringWithUTF8String:type];
+ NSString* const uti = utiForMimeType(mimeType);
+ NSData* const blob = [NSData dataWithBytes:data length:len];
- [pasteboard declareTypes:[NSArray arrayWithObjects:uti, nil] owner:nil];
+ [pasteboard declareTypes:[NSArray arrayWithObjects:uti, nil] owner:nil];
- if ([pasteboard setData:blob forType:uti]) {
- return PUGL_SUCCESS;
+ if ([pasteboard setData:blob forType:uti]) {
+ return PUGL_SUCCESS;
+ }
}
return PUGL_FAILURE;