diff options
author | David Robillard <d@drobilla.net> | 2022-05-22 17:48:16 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-11-11 09:49:51 -0500 |
commit | c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6 (patch) | |
tree | ca5e6f85207f3f51bd3015a67c23d9dd0c917846 /test | |
parent | 32733abab8546b708cab59a4df09f92eb3214f73 (diff) | |
download | pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.tar.gz pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.tar.bz2 pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.zip |
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.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_local_copy_paste.c | 27 | ||||
-rw-r--r-- | test/test_remote_copy_paste.c | 12 |
2 files changed, 25 insertions, 14 deletions
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); |