aboutsummaryrefslogtreecommitdiffstats
path: root/doc/c/clipboards.rst
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-22 17:48:16 -0400
committerDavid Robillard <d@drobilla.net>2023-11-11 09:49:51 -0500
commitc59e88aa6fa60c6f7424da737fcaf0496a0bf3d6 (patch)
treeca5e6f85207f3f51bd3015a67c23d9dd0c917846 /doc/c/clipboards.rst
parent32733abab8546b708cab59a4df09f92eb3214f73 (diff)
downloadpugl-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 'doc/c/clipboards.rst')
-rw-r--r--doc/c/clipboards.rst14
1 files changed, 8 insertions, 6 deletions
diff --git a/doc/c/clipboards.rst b/doc/c/clipboards.rst
index 44f2960..c7b6ef4 100644
--- a/doc/c/clipboards.rst
+++ b/doc/c/clipboards.rst
@@ -66,10 +66,11 @@ When handling this event,
static void
onDataOffer(PuglView* view, const PuglEventDataOffer* event)
{
- size_t numTypes = puglGetNumClipboardTypes(view, clipboard);
+ PuglClipboard clipboard = event->clipboard;
+ size_t numTypes = puglGetNumClipboardTypes(view, clipboard);
for (uint32_t t = 0; t < numTypes; ++t) {
- const char* type = puglGetClipboardType(view, t);
+ const char* type = puglGetClipboardType(view, clipboard, t);
printf("Offered type: %s\n", type);
}
}
@@ -80,7 +81,7 @@ it can accept the offer with :func:`puglAcceptOffer`:
.. code-block:: c
for (uint32_t t = 0; t < numTypes; ++t) {
- const char* type = puglGetClipboardType(view, t);
+ const char* type = puglGetClipboardType(view, clipboard, t);
if (!strcmp(type, "text/uri-list")) {
puglAcceptOffer(view,
event,
@@ -109,15 +110,16 @@ the data can be fetched with :func:`puglGetClipboard`:
static void
onData(PuglView* view, const PuglEventData* event)
{
- uint32_t typeIndex = event->typeIndex;
+ PuglClipboard clipboard = event->clipboard;
+ uint32_t typeIndex = event->typeIndex;
- const char* type = puglGetClipboardType(view, typeIndex);
+ const char* type = puglGetClipboardType(view, clipboard, typeIndex);
fprintf(stderr, "Received data type: %s\n", type);
if (!strcmp(type, "text/plain")) {
size_t len = 0;
- const void* data = puglGetClipboard(view, typeIndex, &len);
+ const void* data = puglGetClipboard(view, clipboard, typeIndex, &len);
printf("Dropped: %s\n", (const char*)data);
}