From c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 22 May 2022 17:48:16 -0400 Subject: Add API support for multiple clipboards Adds a PuglClipboard enum, and uses it everywhere necessary to "structurally" support multiple clipboards. Towards re-using this API to support DnD. --- test/test_local_copy_paste.c | 27 +++++++++++++++++---------- test/test_remote_copy_paste.c | 12 ++++++++---- 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/test_local_copy_paste.c b/test/test_local_copy_paste.c index 1d0d3fc..9aa4cba 100644 --- a/test/test_local_copy_paste.c +++ b/test/test_local_copy_paste.c @@ -57,23 +57,29 @@ onEvent(PuglView* view, const PuglEvent* event) assert(event->timer.id == timerId); if (test->iteration == 0) { - puglSetClipboard( - view, "text/plain", "Copied Text", strlen("Copied Text") + 1); + puglSetClipboard(view, + PUGL_CLIPBOARD_GENERAL, + "text/plain", + "Copied Text", + strlen("Copied Text") + 1); // Check that the new type is available immediately - assert(puglGetNumClipboardTypes(view) >= 1); - assert(!strcmp(puglGetClipboardType(view, 0), "text/plain")); + assert(puglGetNumClipboardTypes(view, PUGL_CLIPBOARD_GENERAL) == 1); + assert(!strcmp(puglGetClipboardType(view, PUGL_CLIPBOARD_GENERAL, 0), + "text/plain")); - size_t len = 0; - const char* text = (const char*)puglGetClipboard(view, 0, &len); + size_t len = 0; + const char* text = + (const char*)puglGetClipboard(view, PUGL_CLIPBOARD_GENERAL, 0, &len); // Check that the new contents are available immediately assert(text); assert(!strcmp(text, "Copied Text")); } else if (test->iteration == 1) { - size_t len = 0; - const char* text = (const char*)puglGetClipboard(view, 0, &len); + size_t len = 0; + const char* text = + (const char*)puglGetClipboard(view, PUGL_CLIPBOARD_GENERAL, 0, &len); // Check that the contents we pasted last iteration are still there assert(text); @@ -98,8 +104,9 @@ onEvent(PuglView* view, const PuglEvent* event) case PUGL_DATA: if (test->state == RECEIVED_OFFER) { - size_t len = 0; - const char* text = (const char*)puglGetClipboard(view, 0, &len); + size_t len = 0; + const char* text = + (const char*)puglGetClipboard(view, PUGL_CLIPBOARD_GENERAL, 0, &len); // Check that the offered data is what we copied earlier assert(text); diff --git a/test/test_remote_copy_paste.c b/test/test_remote_copy_paste.c index 8e2b752..de5a61b 100644 --- a/test/test_remote_copy_paste.c +++ b/test/test_remote_copy_paste.c @@ -60,8 +60,11 @@ onCopierEvent(PuglView* const view, const PuglEvent* const event) assert(event->timer.id == copierTimerId); if (test->state < COPIED) { - puglSetClipboard( - view, "text/plain", "Copied Text", strlen("Copied Text") + 1); + puglSetClipboard(view, + PUGL_CLIPBOARD_GENERAL, + "text/plain", + "Copied Text", + strlen("Copied Text") + 1); test->state = COPIED; } @@ -111,8 +114,9 @@ onPasterEvent(PuglView* const view, const PuglEvent* const event) case PUGL_DATA: if (test->state == RECEIVED_OFFER) { - size_t len = 0; - const char* text = (const char*)puglGetClipboard(view, 0, &len); + size_t len = 0; + const char* text = + (const char*)puglGetClipboard(view, PUGL_CLIPBOARD_GENERAL, 0, &len); // Check that the offered data is what we copied earlier assert(text); -- cgit v1.2.1